diff --git a/ChangeLog b/ChangeLog index 3f0469400..cb0a5eaa7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2010-02-25 Richard Frith-Macdonald + + * configure.ac: Add test for socklen_t type + * configure: regenerate + * Headers/Additions/GNUstepBase/config.h.in: regenerate + * Source/GSNetwork.h: + * Source/NSSocketPort.m: Fix for socklen_t + * Source/NSMapTable.m: + * Source/GSHTTPURLHandle.m: + * Source/NSConcreteMapTable.m: + * Source/NSConcreteHashTable.m: + * Headers/Foundation/NSHashTable.h: + * Headers/Foundation/NSMapTable.h: + Use NSUInteger values for OSX API compatibility + 2010-02-25 Richard Frith-Macdonald * Source/ObjectiveC2/runtime.c: diff --git a/Headers/Additions/GNUstepBase/config.h.in b/Headers/Additions/GNUstepBase/config.h.in index 65922addc..d7896f2e8 100644 --- a/Headers/Additions/GNUstepBase/config.h.in +++ b/Headers/Additions/GNUstepBase/config.h.in @@ -214,6 +214,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_OBJC_RUNTIME_H +/* Define to 1 if you have the `objc_setProperty' function. */ +#undef HAVE_OBJC_SETPROPERTY + /* Define to 1 if you have the `objc_sync_enter' function. */ #undef HAVE_OBJC_SYNC_ENTER @@ -292,6 +295,9 @@ /* Define to 1 if you have the `sigsetjmp' function. */ #undef HAVE_SIGSETJMP +/* Define to 1 if the system has the type `socklen_t'. */ +#undef HAVE_SOCKLEN_T + /* Define to 1 if you have the `statvfs' function. */ #undef HAVE_STATVFS @@ -486,31 +492,31 @@ /* Define to 1 if the `setpgrp' function takes no argument. */ #undef SETPGRP_VOID -/* The size of a `double', as computed by sizeof. */ +/* The size of `double', as computed by sizeof. */ #undef SIZEOF_DOUBLE -/* The size of a `float', as computed by sizeof. */ +/* The size of `float', as computed by sizeof. */ #undef SIZEOF_FLOAT -/* The size of a `int', as computed by sizeof. */ +/* The size of `int', as computed by sizeof. */ #undef SIZEOF_INT -/* The size of a `long', as computed by sizeof. */ +/* The size of `long', as computed by sizeof. */ #undef SIZEOF_LONG -/* The size of a `long long', as computed by sizeof. */ +/* The size of `long long', as computed by sizeof. */ #undef SIZEOF_LONG_LONG -/* The size of a `pthread_cond_t', as computed by sizeof. */ +/* The size of `pthread_cond_t', as computed by sizeof. */ #undef SIZEOF_PTHREAD_COND_T -/* The size of a `pthread_mutex_t', as computed by sizeof. */ +/* The size of `pthread_mutex_t', as computed by sizeof. */ #undef SIZEOF_PTHREAD_MUTEX_T -/* The size of a `short', as computed by sizeof. */ +/* The size of `short', as computed by sizeof. */ #undef SIZEOF_SHORT -/* The size of a `void*', as computed by sizeof. */ +/* The size of `void*', as computed by sizeof. */ #undef SIZEOF_VOIDP /* Define to 1 if you have the ANSI C header files. */ @@ -538,5 +544,5 @@ #undef inline #endif -/* Define to `unsigned' if does not define. */ +/* Define to `unsigned int' if does not define. */ #undef size_t diff --git a/Headers/Foundation/NSHashTable.h b/Headers/Foundation/NSHashTable.h index ed416a6e8..e8ac7c0c6 100644 --- a/Headers/Foundation/NSHashTable.h +++ b/Headers/Foundation/NSHashTable.h @@ -157,11 +157,11 @@ typedef struct { void *map; void *node; size_t bucket; } NSHashEnumerator; /** Callback functions for an NSHashTable. See NSCreateHashTable() .
*/ typedef struct _NSHashTableCallBacks { - /** unsigned int (*hash)(NSHashTable *, const void *) ... + /** NSUInteger (*hash)(NSHashTable *, const void *) ... * Hashing function. NOTE: Elements with equal values must have equal hash * function values. The default if NULL uses the pointer addresses * directly.
*/ - unsigned int (*hash)(NSHashTable *, const void *); + NSUInteger (*hash)(NSHashTable *, const void *); /** BOOL (*isEqual)(NSHashTable *, const void *, const void *) * ... Comparison function. The default if NULL uses '=='. @@ -192,11 +192,11 @@ GS_EXPORT const NSHashTableCallBacks NSPointerToStructHashCallBacks; GS_EXPORT NSHashTable * NSCreateHashTable(NSHashTableCallBacks callBacks, - unsigned int capacity); + NSUInteger capacity); GS_EXPORT NSHashTable * NSCreateHashTableWithZone(NSHashTableCallBacks callBacks, - unsigned int capacity, + NSUInteger capacity, NSZone *zone); GS_EXPORT NSHashTable * @@ -211,7 +211,7 @@ NSResetHashTable(NSHashTable *table); GS_EXPORT BOOL NSCompareHashTables(NSHashTable *table1, NSHashTable *table2); -GS_EXPORT unsigned int +GS_EXPORT NSUInteger NSCountHashTable(NSHashTable *table); GS_EXPORT void * diff --git a/Headers/Foundation/NSMapTable.h b/Headers/Foundation/NSMapTable.h index a88f755c2..3b5d1c40e 100644 --- a/Headers/Foundation/NSMapTable.h +++ b/Headers/Foundation/NSMapTable.h @@ -159,7 +159,7 @@ typedef struct _NSMapTableKeyCallBacks * NOTE: Elements with equal values must * have equal hash function values. */ - unsigned (*hash)(NSMapTable *, const void *); + NSUInteger (*hash)(NSMapTable *, const void *); /** * Comparison function. Must not modify either key. @@ -242,12 +242,12 @@ GS_EXPORT const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks; GS_EXPORT NSMapTable * NSCreateMapTable(NSMapTableKeyCallBacks keyCallBacks, NSMapTableValueCallBacks valueCallBacks, - unsigned int capacity); + NSUInteger capacity); GS_EXPORT NSMapTable * NSCreateMapTableWithZone(NSMapTableKeyCallBacks keyCallBacks, NSMapTableValueCallBacks valueCallBacks, - unsigned int capacity, + NSUInteger capacity, NSZone *zone); GS_EXPORT NSMapTable * @@ -262,7 +262,7 @@ NSResetMapTable(NSMapTable *table); GS_EXPORT BOOL NSCompareMapTables(NSMapTable *table1, NSMapTable *table2); -GS_EXPORT unsigned int +GS_EXPORT NSUInteger NSCountMapTable(NSMapTable *table); GS_EXPORT BOOL diff --git a/Source/GSHTTPURLHandle.m b/Source/GSHTTPURLHandle.m index 33c1bc0df..fb120dae5 100644 --- a/Source/GSHTTPURLHandle.m +++ b/Source/GSHTTPURLHandle.m @@ -69,7 +69,7 @@ * in case the remote server is buggy and requires particular * captialisation of headers (some http software is faulty like that). */ -static unsigned int +static NSUInteger _id_hash(void *table, NSString* o) { return [[o uppercaseString] hash]; @@ -81,7 +81,7 @@ _id_is_equal(void *table, NSString *o, NSString *p) return ([o caseInsensitiveCompare: p] == NSOrderedSame) ? YES : NO; } -typedef unsigned int (*NSMT_hash_func_t)(NSMapTable *, const void *); +typedef NSUInteger (*NSMT_hash_func_t)(NSMapTable *, const void *); typedef BOOL (*NSMT_is_equal_func_t)(NSMapTable *, const void *, const void *); typedef void (*NSMT_retain_func_t)(NSMapTable *, const void *); typedef void (*NSMT_release_func_t)(NSMapTable *, void *); diff --git a/Source/GSNetwork.h b/Source/GSNetwork.h index 72b95acfd..76f99f5c7 100644 --- a/Source/GSNetwork.h +++ b/Source/GSNetwork.h @@ -82,8 +82,10 @@ #define IN6ADDRSZ 16 #endif -#ifndef socklen_t -#define socklen_t uint32_t +#if !defined(HAVE_SOCKLEN_T) +# if !defined(socklen_t) +# define socklen_t uint32_t +# endif #endif #endif diff --git a/Source/NSConcreteHashTable.m b/Source/NSConcreteHashTable.m index 4388d50a4..8fc886b4b 100644 --- a/Source/NSConcreteHashTable.m +++ b/Source/NSConcreteHashTable.m @@ -259,7 +259,7 @@ NSCopyHashTableWithZone(NSHashTable *table, NSZone *zone) /** * Returns the number of items in the table. */ -unsigned int +NSUInteger NSCountHashTable(NSHashTable *table) { return [table count]; @@ -275,7 +275,7 @@ NSCountHashTable(NSHashTable *table) NSHashTable * NSCreateHashTable( NSHashTableCallBacks callBacks, - unsigned int capacity) + NSUInteger capacity) { return NSCreateHashTableWithZone(callBacks, capacity, NSDefaultMallocZone()); } @@ -292,7 +292,7 @@ NSCreateHashTable( NSHashTable * NSCreateHashTableWithZone( NSHashTableCallBacks k, - unsigned int capacity, + NSUInteger capacity, NSZone *zone) { GSIMapTable table; @@ -726,7 +726,7 @@ NSStringFromHashTable(NSHashTable *table) /* These are to increase readabilty locally. */ -typedef unsigned int (*NSHT_hash_func_t)(NSHashTable *, const void *); +typedef NSUInteger (*NSHT_hash_func_t)(NSHashTable *, const void *); typedef BOOL (*NSHT_isEqual_func_t)(NSHashTable *, const void *, const void *); typedef void (*NSHT_retain_func_t)(NSHashTable *, const void *); typedef void (*NSHT_release_func_t)(NSHashTable *, void *); @@ -855,7 +855,7 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks = - (NSArray*) allObjects { NSHashEnumerator enumerator; - unsigned index; + NSUInteger index; NSArray *a; GS_BEGINITEMBUF(objects, nodeCount, id); diff --git a/Source/NSConcreteMapTable.m b/Source/NSConcreteMapTable.m index e9cd94a51..5bc9a373f 100644 --- a/Source/NSConcreteMapTable.m +++ b/Source/NSConcreteMapTable.m @@ -385,7 +385,7 @@ NSCopyMapTableWithZone(NSMapTable *table, NSZone *zone) /** * Returns the number of key/value pairs in the table. */ -unsigned int +NSUInteger NSCountMapTable(NSMapTable *table) { if (table == nil) @@ -411,7 +411,7 @@ NSMapTable * NSCreateMapTable( NSMapTableKeyCallBacks keyCallBacks, NSMapTableValueCallBacks valueCallBacks, - unsigned int capacity) + NSUInteger capacity) { return NSCreateMapTableWithZone(keyCallBacks, valueCallBacks, capacity, NSDefaultMallocZone()); @@ -430,7 +430,7 @@ NSMapTable * NSCreateMapTableWithZone( NSMapTableKeyCallBacks k, NSMapTableValueCallBacks v, - unsigned int capacity, + NSUInteger capacity, NSZone *zone) { GSIMapTable table; @@ -1002,7 +1002,7 @@ NSStringFromMapTable(NSMapTable *table) /* These are to increase readabilty locally. */ -typedef unsigned int (*NSMT_hash_func_t)(NSMapTable *, const void *); +typedef NSUInteger (*NSMT_hash_func_t)(NSMapTable *, const void *); typedef BOOL (*NSMT_is_equal_func_t)(NSMapTable *, const void *, const void *); typedef void (*NSMT_retain_func_t)(NSMapTable *, const void *); typedef void (*NSMT_release_func_t)(NSMapTable *, void *); diff --git a/Source/NSMapTable.m b/Source/NSMapTable.m index 23b2d14fe..83e1269a0 100644 --- a/Source/NSMapTable.m +++ b/Source/NSMapTable.m @@ -133,14 +133,16 @@ static Class concreteClass = 0; - (NSUInteger) count { - return (NSUInteger)[self subclassResponsibility: _cmd]; + [self subclassResponsibility: _cmd]; + return (NSUInteger)0; } - (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state objects: (id*)stackbuf count: (NSUInteger)len { - return (NSUInteger)[self subclassResponsibility: _cmd]; + [self subclassResponsibility: _cmd]; + return (NSUInteger)0; } - (NSDictionary*) dictionaryRepresentation @@ -201,7 +203,7 @@ static Class concreteClass = 0; - (void) removeAllObjects { - unsigned count = [self count]; + NSUInteger count = [self count]; if (count > 0) { diff --git a/Source/NSSocketPort.m b/Source/NSSocketPort.m index 1f7d9a4b2..aeb2c0841 100644 --- a/Source/NSSocketPort.m +++ b/Source/NSSocketPort.m @@ -2150,7 +2150,7 @@ static Class tcpPortClass; #endif { struct sockaddr_in sockAddr; - size_t size = sizeof(sockAddr); + socklen_t size = sizeof(sockAddr); desc = accept(listener, (struct sockaddr*)&sockAddr, &size); if (desc == INVALID_SOCKET) diff --git a/configure b/configure index 43856ee9f..af861e058 100755 --- a/configure +++ b/configure @@ -11372,6 +11372,68 @@ fi done +{ echo "$as_me:$LINENO: checking for socklen_t" >&5 +echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6; } +if test "${ac_cv_type_socklen_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef socklen_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_socklen_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_socklen_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_socklen_t" >&5 +echo "${ECHO_T}$ac_cv_type_socklen_t" >&6; } +if test $ac_cv_type_socklen_t = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_SOCKLEN_T 1 +_ACEOF + + +fi + #-------------------------------------------------------------------- # These headers/functions needed for stacktrace in NSException.m diff --git a/configure.ac b/configure.ac index 4a1c06c14..03dbeba1d 100644 --- a/configure.ac +++ b/configure.ac @@ -802,6 +802,7 @@ fi # These headers/functions needed by GSTcpPort.m #-------------------------------------------------------------------- AC_CHECK_HEADERS(sys/socket.h netinet/in.h) +AC_CHECK_TYPES([socklen_t]) dnl AC_REPLACE_FUNCS(recvfrom) #--------------------------------------------------------------------