From 5993965112da00e29ebdb2be084b50bae5cbb90f Mon Sep 17 00:00:00 2001 From: Marcio Barbosa Date: Wed, 23 Mar 2022 17:58:41 -0300 Subject: [PATCH] DARWIN: Declare/include functions before using them Every function should be explicitly declared before it can be called. Since -Wimplicit-function-declaration is usually a warning and not an error, calling undeclared functions does not prevent us from building the code. However, apple-clang 12 makes this an error by default, prohibiting the build of the current version on macOS 11 (Big Sur). To fix this problem, declare functions before calling them. Also, include mach/thread_act.h into afs_call.c so the declaration of thread_terminate() can be found on macOS. Last, given that the third argument of PIOCTL() (if UKERNEL is defined) is a pointer, cast it to 'long'. Doing so, we can avoid another inhibited warning. Notice that this PIOCTL definition is scoped to a single file (src/auth/ktc.c). Reviewed-on: https://gerrit.openafs.org/14744 Reviewed-by: Andrew Deason Reviewed-by: Cheyenne Wills Reviewed-by: Benjamin Kaduk Tested-by: BuildBot (cherry picked from commit f9c96d0fd609e14fcb8ff7d9269024e026f742cb) Change-Id: I70dadc44d40e1fc877f9e0490e28636907432faa Reviewed-on: https://gerrit.openafs.org/15246 Reviewed-by: Michael Meffie Reviewed-by: Harish Sharma Reviewed-by: Stephan Wiesand Tested-by: Stephan Wiesand --- CODING | 1 - src/afs/UKERNEL/afs_usrops.c | 1 - src/afs/UKERNEL/afs_usrops.h | 3 ++- src/afs/UKERNEL/afsd_uafs.c | 1 - src/afs/afs_call.c | 4 ++++ src/afs/afs_prototypes.h | 6 ++++++ src/auth/ktc.c | 5 +++-- src/libafs/MakefileProto.DARWIN.in | 27 ++++++++++++++------------- src/libuafs/Makefile.common.in | 2 +- src/rx/DARWIN/rx_kmutex.c | 1 + src/rx/DARWIN/rx_kmutex.h | 2 ++ src/rx/rx_prototypes.h | 4 +++- 12 files changed, 36 insertions(+), 21 deletions(-) diff --git a/CODING b/CODING index 760738f989..e0a81f89e4 100644 --- a/CODING +++ b/CODING @@ -331,7 +331,6 @@ afs/afs_syscall.c : old-style : strict-proto : all (ukernel) : syscall pointer issues afsd/afsd_kernel.c : deprecated : daemon() marked as deprecated on Darwin -auth/ktc.c : all (ukernel) : call_syscall doesn't have a prototype bozo/bosserver.c : deprecated : daemon() marked as deprecated on Darwin bucoord/ubik_db_if.c : strict-proto : ubik_Call_SingleServer bucoord/commands.c : all : signed vs unsigned for dates diff --git a/src/afs/UKERNEL/afs_usrops.c b/src/afs/UKERNEL/afs_usrops.c index 26597dcfd1..13cf64b4eb 100644 --- a/src/afs/UKERNEL/afs_usrops.c +++ b/src/afs/UKERNEL/afs_usrops.c @@ -98,7 +98,6 @@ afs_lock_t osi_fsplock; pthread_mutex_t usr_sleep_mutex; pthread_cond_t usr_sleep_cond; -int call_syscall(long, long, long, long, long, long); int fork_syscall(long, long, long, long, long, long); diff --git a/src/afs/UKERNEL/afs_usrops.h b/src/afs/UKERNEL/afs_usrops.h index 927f4a818e..87711addaa 100644 --- a/src/afs/UKERNEL/afs_usrops.h +++ b/src/afs/UKERNEL/afs_usrops.h @@ -145,5 +145,6 @@ extern void uafs_Shutdown(void); extern void uafs_mount(void); extern void uafs_setMountDir(const char *dir); extern int uafs_access(char *path, int amode); - +extern int call_syscall(long syscall, long afscall, long param1, long param2, + long param3, long param4); #endif /* __AFS_USROPS_H__ */ diff --git a/src/afs/UKERNEL/afsd_uafs.c b/src/afs/UKERNEL/afsd_uafs.c index 5e2dcddf44..470951fccd 100644 --- a/src/afs/UKERNEL/afsd_uafs.c +++ b/src/afs/UKERNEL/afsd_uafs.c @@ -23,7 +23,6 @@ #include "afs/afs_args.h" #include "afsd/afsd.h" -extern int call_syscall(long, long, long, long, long, long); void afsd_mount_afs(const char *rn, const char *mountdir) diff --git a/src/afs/afs_call.c b/src/afs/afs_call.c index e75cce7c86..72c5cfaeeb 100644 --- a/src/afs/afs_call.c +++ b/src/afs/afs_call.c @@ -37,6 +37,10 @@ #endif #include +#if defined(AFS_DARWIN80_ENV) +# include +#endif + #if defined(AFS_SUN5_ENV) || defined(AFS_AIX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV) #define AFS_MINBUFFERS 100 #else diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index b14f2b54f6..cc19895640 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -714,6 +714,9 @@ extern int afs_osi_Write(struct osi_file *afile, afs_int32 offset, extern int afs_osi_MapStrategy(int (*aproc) (struct buf * bp), struct buf *bp); extern void shutdown_osifile(void); +#if defined(AFS_HAVE_VXFS) || defined(AFS_DARWIN_ENV) +extern void afs_InitDualFSCacheOps(struct vnode *vp); +#endif /* ARCH/osi_groups.c */ @@ -732,6 +735,9 @@ extern int setpag(afs_proc_t *proc, afs_ucred_t **cred, afs_uint32 pagvalue, #elif defined(AFS_OBSD_ENV) extern int setpag(afs_proc_t *proc, struct ucred **cred, afs_uint32 pagvalue, afs_uint32 * newpag, int change_parent); +#elif defined(AFS_DARWIN_ENV) +extern int setpag(struct proc *proc, struct ucred **cred, afs_uint32 pagvalue, + afs_uint32 *newpag, afs_uint32 change_parent); #endif /* UKERNEL */ #if defined(AFS_LINUX_ENV) || defined(AFS_PAG_ONEGROUP_ENV) diff --git a/src/auth/ktc.c b/src/auth/ktc.c index 84879ef5ef..b26bd6e3c6 100644 --- a/src/auth/ktc.c +++ b/src/auth/ktc.c @@ -24,7 +24,8 @@ #endif #if defined(UKERNEL) -#include "afsincludes.h" +# include "afsincludes.h" +# include #endif #ifdef AFS_AIX_ENV @@ -119,7 +120,7 @@ static void ktc_LocalCell(void); #endif /* AFS_KERBEROS_ENV */ #if defined(UKERNEL) -#define PIOCTL(A,B,C,D) (errno = (call_syscall(AFSCALL_PIOCTL,A,B,C,D)), errno?-1:0) +#define PIOCTL(A,B,C,D) (errno = (call_syscall(AFSCALL_PIOCTL,A,B,(long)C,D,0)), errno?-1:0) #else #define PIOCTL pioctl #endif diff --git a/src/libafs/MakefileProto.DARWIN.in b/src/libafs/MakefileProto.DARWIN.in index 3ee238a8d0..6fb51736df 100644 --- a/src/libafs/MakefileProto.DARWIN.in +++ b/src/libafs/MakefileProto.DARWIN.in @@ -65,9 +65,9 @@ MODLD=$(CC) -static $(KOPTS_DBUG) -nostdlib $(ARCHFLAGS) -CFLAGS_ppc=${KINCLUDES} -I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS_ppc) $(KOPTS_DBUG) -CFLAGS_x86=${KINCLUDES} -I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS_x86) $(KOPTS_DBUG) -CFLAGS_amd64=${KINCLUDES} -I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS_amd64) $(KOPTS_DBUG) +CFLAGS_ppc=-I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS_ppc) $(KOPTS_DBUG) +CFLAGS_x86=-I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS_x86) $(KOPTS_DBUG) +CFLAGS_amd64=-I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS_amd64) $(KOPTS_DBUG) # Name of directory to hold object files and libraries. @@ -81,31 +81,32 @@ DESTDIRS = single_destdir include Makefile.common +ALL_COMMON_INCLUDES=$(KINCLUDES) $(COMMON_INCLUDE) # override suffix rule; unfortunately, this causes a warning message .c.o: if [ "$(ARCH_ppc)" = "yes" ]; then \ - $(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_ppc) $(CFLAGS-$@) -o $(patsubst %.o,%.o.ppc,$@) -c $< || exit(1) \ + $(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(CFLAGS_ppc) $(CFLAGS-$@) -o $(patsubst %.o,%.o.ppc,$@) -c $< || exit(1) \ fi \ if [ "$(ARCH_x86)" = "yes" ]; then \ - $(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_x86) $(CFLAGS-$@) -o $(patsubst %.o,%.o.x86,$@) -c $< || exit(1) \ + $(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(CFLAGS_x86) $(CFLAGS-$@) -o $(patsubst %.o,%.o.x86,$@) -c $< || exit(1) \ fi if [ "$(ARCH_amd64)" = "yes" ]; then \ - $(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_amd64) $(CFLAGS-$@) -o $(patsubst %.o,%.o.amd64,$@) -c $< || exit(1) \ + $(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(CFLAGS_amd64) $(CFLAGS-$@) -o $(patsubst %.o,%.o.amd64,$@) -c $< || exit(1) \ fi \ lipo -create ${OBJ_ppc} ${OBJ_x86} ${OBJ_amd64} -output $@; -CRULE_NOOPT_ppc=$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_ppc) $(CFLAGS-$@) -o $(patsubst %.o,%.o.ppc,$@) -c $? -CRULE_NOOPT_x86=$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_x86) $(CFLAGS-$@) -o $(patsubst %.o,%.o.x86,$@) -c $? -CRULE_NOOPT_amd64=$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_amd64) $(CFLAGS-$@) -o $(patsubst %.o,%.o.amd64,$@) -c $? +CRULE_NOOPT_ppc=$(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(CFLAGS_ppc) $(CFLAGS-$@) -o $(patsubst %.o,%.o.ppc,$@) -c $? +CRULE_NOOPT_x86=$(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(CFLAGS_x86) $(CFLAGS-$@) -o $(patsubst %.o,%.o.x86,$@) -c $? +CRULE_NOOPT_amd64=$(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(CFLAGS_amd64) $(CFLAGS-$@) -o $(patsubst %.o,%.o.amd64,$@) -c $? CRULE_NOOPT=$(shell echo "${ARCH_ppc}" | grep -q -w yes && echo "${CRULE_NOOPT_ppc} && "; echo "${ARCH_x86}" | grep -q -w yes && echo "${CRULE_NOOPT_x86} && "; echo "${ARCH_amd64}" | grep -q -w yes && echo "${CRULE_NOOPT_amd64} && "; echo " lipo -create ${OBJ_ppc} ${OBJ_x86} ${OBJ_amd64} -output $@ && true") -CRULE_OPT_ppc=$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS_ppc) $(CFLAGS-$@) -o $(patsubst %.o,%.o.ppc,$@) -c $? -CRULE_OPT_x86=$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS_x86) $(CFLAGS-$@) -o $(patsubst %.o,%.o.x86,$@) -c $? -CRULE_OPT_amd64=$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS_amd64) $(CFLAGS-$@) -o $(patsubst %.o,%.o.amd64,$@) -c $? +CRULE_OPT_ppc=$(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS_ppc) $(CFLAGS-$@) -o $(patsubst %.o,%.o.ppc,$@) -c $? +CRULE_OPT_x86=$(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS_x86) $(CFLAGS-$@) -o $(patsubst %.o,%.o.x86,$@) -c $? +CRULE_OPT_amd64=$(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS_amd64) $(CFLAGS-$@) -o $(patsubst %.o,%.o.amd64,$@) -c $? CRULE_OPT=$(shell echo "${ARCH_ppc}" | grep -q -w yes && echo "${CRULE_OPT_ppc} && "; echo "${ARCH_x86}" | grep -q -w yes && echo "${CRULE_OPT_x86} && "; echo "${ARCH_amd64}" | grep -q -w yes && echo "${CRULE_OPT_amd64} && ";echo "lipo -create ${OBJ_ppc} ${OBJ_x86} ${OBJ_amd64} -output $@ && true") -CFLAGS=${KINCLUDES} -I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS) +CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS) KOPTS=-static -fno-common -finline -fno-keep-inline-functions -force_cpusubtype_ALL -msoft-float -mlong-branch diff --git a/src/libuafs/Makefile.common.in b/src/libuafs/Makefile.common.in index e062c7c2eb..64361de850 100644 --- a/src/libuafs/Makefile.common.in +++ b/src/libuafs/Makefile.common.in @@ -443,7 +443,7 @@ afs_syscall.lo: $(TOP_SRC_AFS)/afs_syscall.c osi_vfsops.lo: $(TOP_SRC_AFS)/UKERNEL/osi_vfsops.c $(LT_CCRULE) $(TOP_SRC_AFS)/UKERNEL/osi_vfsops.c -DAFS_NONFSTRANS ktc.lo: $(TOP_SRCDIR)/auth/ktc.c - $(LT_CCRULE) $(TOP_SRCDIR)/auth/ktc.c @CFLAGS_NOERROR@ + $(LT_CCRULE) $(TOP_SRCDIR)/auth/ktc.c cellconfig.lo: $(TOP_SRCDIR)/auth/cellconfig.c $(LT_CCRULE) $(TOP_SRCDIR)/auth/cellconfig.c keys.lo: $(TOP_SRCDIR)/auth/keys.c diff --git a/src/rx/DARWIN/rx_kmutex.c b/src/rx/DARWIN/rx_kmutex.c index bafb732dfd..678da9d82e 100644 --- a/src/rx/DARWIN/rx_kmutex.c +++ b/src/rx/DARWIN/rx_kmutex.c @@ -16,6 +16,7 @@ #include #include "afs/param.h" +#include "rx_kmutex.h" #ifndef AFS_DARWIN80_ENV /* diff --git a/src/rx/DARWIN/rx_kmutex.h b/src/rx/DARWIN/rx_kmutex.h index 0fe6aa808c..d1a105f01b 100644 --- a/src/rx/DARWIN/rx_kmutex.h +++ b/src/rx/DARWIN/rx_kmutex.h @@ -108,6 +108,8 @@ typedef struct { typedef int afs_kcondvar_t; extern lck_grp_t * openafs_lck_grp; +extern void rx_kmutex_setup(void); +extern void rx_kmutex_finish(void); #define MUTEX_SETUP() rx_kmutex_setup() #define MUTEX_FINISH() rx_kmutex_finish() diff --git a/src/rx/rx_prototypes.h b/src/rx/rx_prototypes.h index 190bb5876a..87a1049f7d 100644 --- a/src/rx/rx_prototypes.h +++ b/src/rx/rx_prototypes.h @@ -316,9 +316,11 @@ extern int osi_NetReceive(osi_socket so, struct sockaddr_in *addr, # if defined(AFS_SUN510_ENV) extern void osi_StartNetIfPoller(void); extern void osi_NetIfPoller(void); -extern void osi_StopNetIfPoller(void); extern struct afs_ifinfo afsifinfo[ADDRSPERSITE]; # endif +# if defined(AFS_SUN510_ENV) || defined(RXK_UPCALL_ENV) +extern void osi_StopNetIfPoller(void); +# endif extern void osi_StopListener(void); extern int rxi_FindIfMTU(afs_uint32 addr); # if defined(UKERNEL)