commit 13f86e09a7683bc31017d2119c012c16fb4f400e
parent 22005154bbfe435320f1bf8a38111fcd63cc77f7
Author: Kris Maglione <jg@suckless.org>
Date: Sat, 26 Jan 2008 22:27:42 -0500
Add <sys/types.h> where needed, thanks to a report by Muzgo, and on wmii-list. Also, add ixp_fstat, and const some parameters.
Diffstat:
13 files changed, 95 insertions(+), 76 deletions(-)
diff --git a/config.mk b/config.mk
@@ -18,7 +18,7 @@ LIBS = -L/usr/lib -lc
# Flags
include $(ROOT)/mk/gcc.mk
-CFLAGS += $(DEBUGCFLAGS) $(INCS)
+CFLAGS += $(DEBUGCFLAGS) -O0 $(INCS)
LDFLAGS = -g $(LDLIBS) $(LIBS)
# Compiler, Linker. Linker should usually *not* be ld.
diff --git a/include/ixp.h b/include/ixp.h
@@ -7,16 +7,14 @@
#include <sys/types.h>
#include <sys/select.h>
-#define IXP_API 86
+#define IXP_API 87
/* Gunk */
-#ifdef IXP_NEEDAPI
-# if IXP_API < IXP_NEEDAPI
-# error A newer version of libixp is needed for this compilation.
-# elif IXP_API > IXP_NEEDAPI && \
- (defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(KENC))
-# warning This version of libixp has a newer API than this compilation suggests.
-# endif
+#if defined(IXP_NEEDAPI) && IXP_API < IXP_NEEDAPI
+# error A newer version of libixp is needed for this compilation.
+#endif
+#if defined(IXP_MAXAPI) && IXP_API > IXP_MAXAPI
+# warning This version of libixp has a newer API than this compilation requires.
#endif
#undef uchar
@@ -499,20 +497,21 @@ int ixp_pthread_init(void);
#endif
/* client.c */
-IxpClient* ixp_mount(char*);
-IxpClient* ixp_mountfd(int);
-void ixp_unmount(IxpClient*);
-IxpCFid* ixp_create(IxpClient*, char*, uint perm, uchar mode);
-IxpCFid* ixp_open(IxpClient*, char*, uchar);
-int ixp_remove(IxpClient*, char*);
-IxpStat* ixp_stat(IxpClient*, char*);
-long ixp_read(IxpCFid*, void*, long);
-long ixp_write(IxpCFid*, const void*, long);
-long ixp_pread(IxpCFid*, void*, long, vlong);
-long ixp_pwrite(IxpCFid*, const void*, long, vlong);
int ixp_close(IxpCFid*);
+Stat* ixp_fstat(IxpCFid*);
+long ixp_pread(IxpCFid*, void*, long, vlong);
int ixp_print(IxpCFid*, const char*, ...);
+long ixp_pwrite(IxpCFid*, const void*, long, vlong);
+long ixp_read(IxpCFid*, void*, long);
+int ixp_remove(IxpClient*, const char*);
+void ixp_unmount(IxpClient*);
int ixp_vprint(IxpCFid*, const char*, va_list);
+long ixp_write(IxpCFid*, const void*, long);
+IxpCFid* ixp_create(IxpClient*, const char*, uint perm, uchar mode);
+IxpClient* ixp_mount(char*);
+IxpClient* ixp_mountfd(int);
+IxpCFid* ixp_open(IxpClient*, const char*, uchar);
+IxpStat* ixp_stat(IxpClient*, const char*);
/* convert.c */
void ixp_pu8(IxpMsg*, uchar*);
@@ -525,7 +524,7 @@ void ixp_pstrings(IxpMsg*, ushort*, char**);
void ixp_pqid(IxpMsg*, IxpQid*);
void ixp_pqids(IxpMsg*, ushort*, IxpQid*);
void ixp_pstat(IxpMsg*, IxpStat*);
-void ixp_pfcall(IxpMsg*, Fcall*);
+void ixp_pfcall(IxpMsg*, IxpFcall*);
/* error.h */
char* ixp_errbuf(void);
@@ -554,8 +553,8 @@ int ixp_serverloop(IxpServer*);
void ixp_server_close(IxpServer*);
/* socket.c */
-int ixp_dial(char*);
-int ixp_announce(char*);
+int ixp_dial(const char*);
+int ixp_announce(const char*);
/* transport.c */
uint ixp_sendmsg(int, IxpMsg*);
diff --git a/include/ixp_local.h b/include/ixp_local.h
@@ -24,7 +24,8 @@ char *argv0;
#ifndef KENC
static inline void _used(long a, ...) { if(a){} }
# define USED(...) _used((long)__VA_ARGS__)
-# define SET(x) USED(&x)
+# define SET(x) (x = 0)
+/* # define SET(x) USED(&x) GCC 4 is 'too smart' for this. */
#endif
#undef nil
diff --git a/libixp/client.c b/libixp/client.c
@@ -3,6 +3,7 @@
*/
#include <assert.h>
#include <stdarg.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -174,13 +175,14 @@ ixp_mount(char *address) {
}
static IxpCFid*
-walk(IxpClient *c, char *path) {
+walk(IxpClient *c, const char *path) {
IxpCFid *f;
+ char *p;
Fcall fcall;
int n;
- path = estrdup(path);
- n = tokenize(fcall.wname, nelem(fcall.wname), path, '/');
+ p = estrdup(path);
+ n = tokenize(fcall.wname, nelem(fcall.wname), p, '/');
f = getfid(c);
fcall.type = TWalk;
@@ -195,7 +197,7 @@ walk(IxpClient *c, char *path) {
f->qid = fcall.wqid[n-1];
ixp_freefcall(&fcall);
- free(path);
+ free(p);
return f;
fail:
putfid(f);
@@ -203,7 +205,7 @@ fail:
}
static IxpCFid*
-walkdir(IxpClient *c, char *path, char **rest) {
+walkdir(IxpClient *c, char *path, const char **rest) {
char *p;
p = path + strlen(path) - 1;
@@ -241,7 +243,7 @@ clunk(IxpCFid *f) {
}
int
-ixp_remove(IxpClient *c, char *path) {
+ixp_remove(IxpClient *c, const char *path) {
Fcall fcall;
IxpCFid *f;
int ret;
@@ -269,7 +271,7 @@ initfid(IxpCFid *f, Fcall *fcall) {
}
IxpCFid*
-ixp_create(IxpClient *c, char *name, uint perm, uchar mode) {
+ixp_create(IxpClient *c, const char *name, uint perm, uchar mode) {
Fcall fcall;
IxpCFid *f;
char *path;;
@@ -282,7 +284,7 @@ ixp_create(IxpClient *c, char *name, uint perm, uchar mode) {
fcall.type = TCreate;
fcall.fid = f->fid;
- fcall.name = name;
+ fcall.name = (char*)(uintptr_t)name;
fcall.perm = perm;
fcall.mode = mode;
@@ -303,7 +305,7 @@ done:
}
IxpCFid*
-ixp_open(IxpClient *c, char *name, uchar mode) {
+ixp_open(IxpClient *c, const char *name, uchar mode) {
Fcall fcall;
IxpCFid *f;
@@ -332,38 +334,48 @@ ixp_close(IxpCFid *f) {
return clunk(f);
}
-Stat*
-ixp_stat(IxpClient *c, char *path) {
+static Stat*
+_stat(IxpClient *c, ulong fid) {
IxpMsg msg;
Fcall fcall;
Stat *stat;
- IxpCFid *f;
-
- stat = nil;
- f = walk(c, path);
- if(f == nil)
- return nil;
fcall.type = TStat;
- fcall.fid = f->fid;
+ fcall.fid = fid;
if(dofcall(c, &fcall) == 0)
- goto done;
+ return nil;
msg = ixp_message((char*)fcall.stat, fcall.nstat, MsgUnpack);
- stat = emalloc(sizeof(*stat));
+ stat = emalloc(sizeof *stat);
ixp_pstat(&msg, stat);
ixp_freefcall(&fcall);
if(msg.pos > msg.end) {
free(stat);
- stat = 0;
+ stat = nil;
}
+ return stat;
+}
-done:
+Stat*
+ixp_stat(IxpClient *c, const char *path) {
+ Stat *stat;
+ IxpCFid *f;
+
+ f = walk(c, path);
+ if(f == nil)
+ return nil;
+
+ stat = _stat(c, f->fid);
clunk(f);
return stat;
}
+Stat*
+ixp_fstat(IxpCFid *f) {
+ return _stat(f->client, f->fid);
+}
+
static long
_pread(IxpCFid *f, char *buf, long count, vlong offset) {
Fcall fcall;
diff --git a/libixp/server.c b/libixp/server.c
@@ -4,6 +4,7 @@
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
+#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include "ixp_local.h"
diff --git a/libixp/socket.c b/libixp/socket.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
+#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -221,7 +222,7 @@ struct addrtab {
};
static int
-lookup(char *address, addrtab *tab) {
+lookup(const char *address, addrtab *tab) {
char *addr, *type;
int ret;
@@ -246,12 +247,12 @@ lookup(char *address, addrtab *tab) {
}
int
-ixp_dial(char *address) {
+ixp_dial(const char *address) {
return lookup(address, dtab);
}
int
-ixp_announce(char *address) {
+ixp_announce(const char *address) {
return lookup(address, atab);
}
diff --git a/mk/dir.mk b/mk/dir.mk
@@ -1,10 +1,10 @@
-MKSUBDIR = targ=$@; \
+MKSUBDIR = targ=$@; targ=$${targ\#d}; \
for i in $$dirs; do \
if [ ! -d $$i ]; then \
echo Skipping nonexistent directory: $$i 1>&2; \
else \
- echo MAKE $${targ\#d} $(BASE)$$i/; \
- (cd $$i && $(MAKE) BASE="$(BASE)$$i/" $${targ\#d}) || exit $?; \
+ echo MAKE $$targ $(BASE)$$i/; \
+ (cd $$i && $(MAKE) BASE="$(BASE)$$i/" $$targ) || exit $?; \
fi; \
done
diff --git a/mk/gcc.mk b/mk/gcc.mk
@@ -26,5 +26,5 @@ CFLAGS += \
-Wtrigraphs
MKDEP = cpp -M
SOCFLAGS += -fPIC
-SOLDFLAGS += -shared -soname $(SONAME)
+SOLDFLAGS += -shared -Wl,-soname=$(SONAME)
diff --git a/mk/hdr.mk b/mk/hdr.mk
@@ -1,10 +1,27 @@
+FILTER = cat
+EXCFLAGS = -I$$(echo $(INCPATH)|sed 's/:/ -I/g') -D_XOPEN_SOURCE=600
+COMPILE= CC="$(CC)" CFLAGS="$(EXCFLAGS) $(CFLAGS)" $(ROOT)/util/compile
+COMPILEPIC= CC="$(CC)" CFLAGS="$(EXCFLAGS) $(CFLAGS) $(SOCFLAGS)" $(ROOT)/util/compile
+LINK= LD="$(LD)" LDFLAGS="$(LDFLAGS)" $(ROOT)/util/link
+LINKSO= LD="$(LD)" LDFLAGS="$(SOLDFLAGS) $(SHARED)" $(ROOT)/util/link
+CLEANNAME=$(ROOT)/util/cleanname
+SOEXT=so
+
+include $(ROOT)/config.mk
+
+# I hate this.
+MKCFGSH=if test -f $(ROOT)/config.local.mk; then echo $(ROOT)/config.local.mk; else echo /dev/null; fi
+MKCFG:=${shell $(MKCFGSH)}
+MKCFG!=${MKCFGSH}
+include $(MKCFG)
+
.SILENT:
-.SUFFIXES: .O .o .o_pic .c .sh .rc .so .awk .1 .depend .install .uninstall .clean
+.SUFFIXES: .O .o .o_pic .c .sh .rc .$(SOEXT) .awk .1 .depend .install .uninstall .clean
all:
.c.depend:
echo MKDEP $<
- $(MKDEP) $(CFLAGS) $< >>.depend
+ $(MKDEP) $(EXCFLAGS) $(CFLAGS) $< >>.depend
.sh.depend .rc.depend .1.depend .awk.depend:
:
@@ -40,11 +57,11 @@ all:
echo UNINSTALL $$($(CLEANNAME) $(BASE)$*)
rm -f $(BIN)/$*
-.a.install .so.install:
+.a.install .$(SOEXT).install:
echo INSTALL $$($(CLEANNAME) $(BASE)$<)
cp -f $< $(LIBDIR)/$<
chmod 0644 $(LIBDIR)/$<
-.a.uninstall .so.uninstall:
+.a.uninstall .$(SOEXT).uninstall:
echo UNINSTALL $$($(CLEANNAME) $(BASE)$<)
rm -f $(LIBDIR)/$<
@@ -65,9 +82,11 @@ all:
rm -f $(MAN)/man1/$<
.O.clean:
+ echo CLEAN $$($(CLEANNAME) $(BASE)$<)
rm -f $< || true 2>/dev/null
rm -f $*.o || true 2>/dev/null
.o.clean .o_pic.clean:
+ echo CLEAN $$($(CLEANNAME) $(BASE)$<)
rm -f $< || true 2>/dev/null
printinstall:
@@ -76,21 +95,5 @@ clean:
install: printinstall mkdirs
depend: cleandep
-FILTER = cat
-COMPILE= CC="$(CC)" CFLAGS="$(CFLAGS)" $(ROOT)/util/compile
-COMPILEPIC= CC="$(CC)" CFLAGS="$(CFLAGS) $(SOCFLAGS)" $(ROOT)/util/compile
-LINK= LD="$(LD)" LDFLAGS="$(LDFLAGS)" $(ROOT)/util/link
-LINKSO= LD="$(LD)" LDFLAGS="$(SOLDFLAGS)" $(ROOT)/util/link
-CLEANNAME=$(ROOT)/util/cleanname
-
-include $(ROOT)/config.mk
-
-# I hate this.
-MKCFGSH=if test -f $(ROOT)/config.local.mk; then echo $(ROOT)/config.local.mk; else echo /dev/null; fi
-MKCFG:=${shell $(MKCFGSH)}
-MKCFG!=${MKCFGSH}
-include $(MKCFG)
-
-CFLAGS += -I$$(echo $(INCPATH)|sed 's/:/ -I/g')
include $(ROOT)/mk/common.mk
diff --git a/mk/many.mk b/mk/many.mk
@@ -13,6 +13,7 @@ printinstall:
manyclean:
for i in ${TARG:=.o} ${TARG:=.O} $(OFILES); do \
+ echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \
rm -f $$i; \
done 2>/dev/null || true
diff --git a/mk/one.mk b/mk/one.mk
@@ -14,6 +14,7 @@ printinstall:
oneclean:
for i in $(PROG) $(OFILES); do \
+ echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \
rm -f $$i; \
done 2>/dev/null || true
diff --git a/mk/so.mk b/mk/so.mk
@@ -1,6 +1,6 @@
SOPTARG = $(ROOT)/lib/$(TARG)
-SO = $(SOPTARG).so
-SONAME = $(TARG).so
+SO = $(SOPTARG).$(SOEXT)
+SONAME = $(TARG).$(SOEXT)
OFILES_PIC = ${OBJ:=.o_pic}
all: $(HFILES) $(SO)
diff --git a/util/link b/util/link
@@ -26,7 +26,7 @@ $LD -o $outfile $ofiles $LDFLAGS $args >$xtmp 2>&1
status=$?
sed 's/.*: In function `[^:]*: *//' $xtmp | egrep . |
-egrep -v 'is almost always misused|is dangerous, better use'
+egrep -v 'is almost always misused|is dangerous, better use|in statically linked applications requires at runtime'
rm -f $xtmp
exit $status