From 8519ed8d217a484c29e514bb2e6e7c7faa88b20e Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Sat, 11 Jul 2009 14:37:37 +0100 Subject: [PATCH] Make lwp.h always provide fasttime prototypes The fasttime functions are used regardles of whether we're using pthreads or LWP. Previously, lwp.h only provided their prototypes if LWP was in use. Change this so these prototypes are always provided, by refactoring the header a little. In the process, remove some duplicate header includes. Reviewed-on: http://gerrit.openafs.org/56 Verified-by: Derrick Brashear Reviewed-by: Derrick Brashear --- src/lwp/lwp.h | 101 +++++++++++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 50 deletions(-) diff --git a/src/lwp/lwp.h b/src/lwp/lwp.h index 39663341e..a7b3151dc 100644 --- a/src/lwp/lwp.h +++ b/src/lwp/lwp.h @@ -18,14 +18,40 @@ #ifndef __LWP_INCLUDE_ #define __LWP_INCLUDE_ 1 -#if !defined(KERNEL) && !defined(_KMEMUSER) && !defined(AFS_PTHREAD_ENV) +#if !defined(KERNEL) && !defined(_KMEMUSER) #include -#if defined(USE_UCONTEXT) && defined(HAVE_UCONTEXT_H) -#include + +/* External function declarations. */ +#ifdef AFS_NT40_ENV +#ifndef _MFC_VER /*skip if doing Microsoft foundation class */ +#include +#endif +#elif defined(AFS_LINUX20_ENV) +#include +#include +#include #else -#include +# include /* select() prototype */ +# include /* fd_set on older platforms */ +# include /* struct timeval, select() prototype */ +# ifndef FD_SET +# include /* fd_set on newer platforms */ +# endif #endif +/* fasttime.c */ +extern int FT_GetTimeOfDay(struct timeval *tv, struct timezone *tz); +extern int FT_Init(int printErrors, int notReally); +extern int FT_AGetTimeOfDay(struct timeval *tv, struct timezone *tz); +extern unsigned int FT_ApproxTime(void); + +#if !defined(AFS_PTHREAD_ENV) +# if defined(USE_UCONTEXT) && defined(HAVE_UCONTEXT_H) +# include +# else +# include +# endif + #define LWP_SUCCESS 0 #define LWP_EBADPID -1 #define LWP_EBLOCKED -2 @@ -46,9 +72,9 @@ #define LWP_ENOROCKS -15 /* all rocks are in use */ #define LWP_EBADROCK -16 /* the specified rock does not exist */ -#if defined(USE_PTHREADS) || defined(USE_SOLARIS_THREADS) -#ifdef USE_SOLARIS_THREADS -#include +# if defined(USE_PTHREADS) || defined(USE_SOLARIS_THREADS) +# ifdef USE_SOLARIS_THREADS +# include typedef int pthread_t; typedef void *pthread_addr_t; typedef void *pthread_condattr_t; @@ -99,10 +125,10 @@ typedef struct { } pthread_destructor_tab_t; define DTAB_SIZE(size) (sizeof(pthread_destructor_tab_t) + (size) * sizeof(dest_slot_t)) -#else -#include "pthread.h" -#endif -#include +# else +# include "pthread.h" +# endif +# include #define LWP_MAX_PRIORITY 0 #define LWP_NORMAL_PRIORITY 0 @@ -129,23 +155,23 @@ struct rock { /* to hide things associated with this LWP under */ #define DEBUGF 0 -#ifndef BDE_THREADS +# ifndef BDE_THREADS /*#define CMA_DEBUG 1*/ -#endif +# endif -#ifdef CMA_DEBUG -#define LWP_CHECKSTUFF(msg) lwp_checkstuff(msg) -#else -#define LWP_CHECKSTUFF(msg) -#endif +# ifdef CMA_DEBUG +# define LWP_CHECKSTUFF(msg) lwp_checkstuff(msg) +# else +# define LWP_CHECKSTUFF(msg) +# endif -#if DEBUGF -#define debugf(m) printf m -#else -#define debugf(m) -#endif +# if DEBUGF +# define debugf(m) printf m +# else +# define debugf(m) +# endif -#define IOMGR_Poll() LWP_DispatchProcess() +# define IOMGR_Poll() LWP_DispatchProcess() /* * These two macros can be used to enter/exit the LWP context in a CMA @@ -319,24 +345,6 @@ extern int lwp_MaxStackSeen; LWP_CreateProcess((a), (b), (c), (d), (e), (f)) #endif -/* External function declarations. */ -#ifdef AFS_NT40_ENV -#ifndef _MFC_VER /*skip if doing Microsoft foundation class */ -#include -#endif -#elif defined(AFS_LINUX20_ENV) -#include -#include -#include -#else -# include /* select() prototype */ -# include /* fd_set on older platforms */ -# include /* struct timeval, select() prototype */ -# ifndef FD_SET -# include /* fd_set on newer platforms */ -# endif -#endif - #endif /* USE_PTHREADS */ /* iomgr.c */ @@ -350,14 +358,6 @@ extern int IOMGR_Initialize(void); extern void IOMGR_FreeFDSet(fd_set * fds); extern int IOMGR_SoftSig(void *(*aproc) (void *), void *arock); - -/* fasttime.c */ -extern int FT_GetTimeOfDay(struct timeval *tv, struct timezone *tz); -extern int FT_Init(int printErrors, int notReally); -extern int FT_AGetTimeOfDay(struct timeval *tv, struct timezone *tz); -extern unsigned int FT_ApproxTime(void); - - extern int LWP_WaitForKeystroke(int seconds); /* -1 => forever */ extern int LWP_GetResponseKey(int seconds, char *key); extern int LWP_GetLine(char *linebuf, int len); @@ -402,6 +402,7 @@ extern void returnto(struct lwp_context *savearea); /* max time we spend on a select in a Win95 DOS box */ #define IOMGR_WIN95WAITTIME 5000 /* microseconds */ +#endif #endif /* __LWP_INCLUDE_ */ #endif /* !KERNEL && !_KMEMUSER */ -- 2.39.5