compatibility and portability fixes.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29736 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2010-02-25 10:00:48 +00:00
parent 1373a38edf
commit 9fec2dc13d
12 changed files with 124 additions and 36 deletions

View file

@ -1,3 +1,18 @@
2010-02-25 Richard Frith-Macdonald <rfm@gnu.org>
* 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 <rfm@gnu.org> 2010-02-25 Richard Frith-Macdonald <rfm@gnu.org>
* Source/ObjectiveC2/runtime.c: * Source/ObjectiveC2/runtime.c:

View file

@ -214,6 +214,9 @@
/* Define to 1 if you have the <objc/runtime.h> header file. */ /* Define to 1 if you have the <objc/runtime.h> header file. */
#undef HAVE_OBJC_RUNTIME_H #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. */ /* Define to 1 if you have the `objc_sync_enter' function. */
#undef HAVE_OBJC_SYNC_ENTER #undef HAVE_OBJC_SYNC_ENTER
@ -292,6 +295,9 @@
/* Define to 1 if you have the `sigsetjmp' function. */ /* Define to 1 if you have the `sigsetjmp' function. */
#undef HAVE_SIGSETJMP #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. */ /* Define to 1 if you have the `statvfs' function. */
#undef HAVE_STATVFS #undef HAVE_STATVFS
@ -486,31 +492,31 @@
/* Define to 1 if the `setpgrp' function takes no argument. */ /* Define to 1 if the `setpgrp' function takes no argument. */
#undef SETPGRP_VOID #undef SETPGRP_VOID
/* The size of a `double', as computed by sizeof. */ /* The size of `double', as computed by sizeof. */
#undef SIZEOF_DOUBLE #undef SIZEOF_DOUBLE
/* The size of a `float', as computed by sizeof. */ /* The size of `float', as computed by sizeof. */
#undef SIZEOF_FLOAT #undef SIZEOF_FLOAT
/* The size of a `int', as computed by sizeof. */ /* The size of `int', as computed by sizeof. */
#undef SIZEOF_INT #undef SIZEOF_INT
/* The size of a `long', as computed by sizeof. */ /* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG #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 #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 #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 #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 #undef SIZEOF_SHORT
/* The size of a `void*', as computed by sizeof. */ /* The size of `void*', as computed by sizeof. */
#undef SIZEOF_VOIDP #undef SIZEOF_VOIDP
/* Define to 1 if you have the ANSI C header files. */ /* Define to 1 if you have the ANSI C header files. */
@ -538,5 +544,5 @@
#undef inline #undef inline
#endif #endif
/* Define to `unsigned' if <sys/types.h> does not define. */ /* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t #undef size_t

View file

@ -157,11 +157,11 @@ typedef struct { void *map; void *node; size_t bucket; } NSHashEnumerator;
/** Callback functions for an NSHashTable. See NSCreateHashTable() . <br />*/ /** Callback functions for an NSHashTable. See NSCreateHashTable() . <br />*/
typedef struct _NSHashTableCallBacks typedef struct _NSHashTableCallBacks
{ {
/** <code>unsigned int (*hash)(NSHashTable *, const void *)</code> ... /** <code>NSUInteger (*hash)(NSHashTable *, const void *)</code> ...
* Hashing function. NOTE: Elements with equal values must have equal hash * Hashing function. NOTE: Elements with equal values must have equal hash
* function values. The default if NULL uses the pointer addresses * function values. The default if NULL uses the pointer addresses
* directly. <br/>*/ * directly. <br/>*/
unsigned int (*hash)(NSHashTable *, const void *); NSUInteger (*hash)(NSHashTable *, const void *);
/** <code>BOOL (*isEqual)(NSHashTable *, const void *, const void *)</code> /** <code>BOOL (*isEqual)(NSHashTable *, const void *, const void *)</code>
* ... Comparison function. The default if NULL uses '<code>==</code>'. * ... Comparison function. The default if NULL uses '<code>==</code>'.
@ -192,11 +192,11 @@ GS_EXPORT const NSHashTableCallBacks NSPointerToStructHashCallBacks;
GS_EXPORT NSHashTable * GS_EXPORT NSHashTable *
NSCreateHashTable(NSHashTableCallBacks callBacks, NSCreateHashTable(NSHashTableCallBacks callBacks,
unsigned int capacity); NSUInteger capacity);
GS_EXPORT NSHashTable * GS_EXPORT NSHashTable *
NSCreateHashTableWithZone(NSHashTableCallBacks callBacks, NSCreateHashTableWithZone(NSHashTableCallBacks callBacks,
unsigned int capacity, NSUInteger capacity,
NSZone *zone); NSZone *zone);
GS_EXPORT NSHashTable * GS_EXPORT NSHashTable *
@ -211,7 +211,7 @@ NSResetHashTable(NSHashTable *table);
GS_EXPORT BOOL GS_EXPORT BOOL
NSCompareHashTables(NSHashTable *table1, NSHashTable *table2); NSCompareHashTables(NSHashTable *table1, NSHashTable *table2);
GS_EXPORT unsigned int GS_EXPORT NSUInteger
NSCountHashTable(NSHashTable *table); NSCountHashTable(NSHashTable *table);
GS_EXPORT void * GS_EXPORT void *

View file

@ -159,7 +159,7 @@ typedef struct _NSMapTableKeyCallBacks
* NOTE: Elements with equal values must * NOTE: Elements with equal values must
* have equal hash function values. * have equal hash function values.
*/ */
unsigned (*hash)(NSMapTable *, const void *); NSUInteger (*hash)(NSMapTable *, const void *);
/** /**
* Comparison function. Must not modify either key. * Comparison function. Must not modify either key.
@ -242,12 +242,12 @@ GS_EXPORT const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks;
GS_EXPORT NSMapTable * GS_EXPORT NSMapTable *
NSCreateMapTable(NSMapTableKeyCallBacks keyCallBacks, NSCreateMapTable(NSMapTableKeyCallBacks keyCallBacks,
NSMapTableValueCallBacks valueCallBacks, NSMapTableValueCallBacks valueCallBacks,
unsigned int capacity); NSUInteger capacity);
GS_EXPORT NSMapTable * GS_EXPORT NSMapTable *
NSCreateMapTableWithZone(NSMapTableKeyCallBacks keyCallBacks, NSCreateMapTableWithZone(NSMapTableKeyCallBacks keyCallBacks,
NSMapTableValueCallBacks valueCallBacks, NSMapTableValueCallBacks valueCallBacks,
unsigned int capacity, NSUInteger capacity,
NSZone *zone); NSZone *zone);
GS_EXPORT NSMapTable * GS_EXPORT NSMapTable *
@ -262,7 +262,7 @@ NSResetMapTable(NSMapTable *table);
GS_EXPORT BOOL GS_EXPORT BOOL
NSCompareMapTables(NSMapTable *table1, NSMapTable *table2); NSCompareMapTables(NSMapTable *table1, NSMapTable *table2);
GS_EXPORT unsigned int GS_EXPORT NSUInteger
NSCountMapTable(NSMapTable *table); NSCountMapTable(NSMapTable *table);
GS_EXPORT BOOL GS_EXPORT BOOL

View file

@ -69,7 +69,7 @@
* in case the remote server is buggy and requires particular * in case the remote server is buggy and requires particular
* captialisation of headers (some http software is faulty like that). * captialisation of headers (some http software is faulty like that).
*/ */
static unsigned int static NSUInteger
_id_hash(void *table, NSString* o) _id_hash(void *table, NSString* o)
{ {
return [[o uppercaseString] hash]; return [[o uppercaseString] hash];
@ -81,7 +81,7 @@ _id_is_equal(void *table, NSString *o, NSString *p)
return ([o caseInsensitiveCompare: p] == NSOrderedSame) ? YES : NO; 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 BOOL (*NSMT_is_equal_func_t)(NSMapTable *, const void *, const void *);
typedef void (*NSMT_retain_func_t)(NSMapTable *, const void *); typedef void (*NSMT_retain_func_t)(NSMapTable *, const void *);
typedef void (*NSMT_release_func_t)(NSMapTable *, void *); typedef void (*NSMT_release_func_t)(NSMapTable *, void *);

View file

@ -82,8 +82,10 @@
#define IN6ADDRSZ 16 #define IN6ADDRSZ 16
#endif #endif
#ifndef socklen_t #if !defined(HAVE_SOCKLEN_T)
#define socklen_t uint32_t # if !defined(socklen_t)
# define socklen_t uint32_t
# endif
#endif #endif
#endif #endif

View file

@ -259,7 +259,7 @@ NSCopyHashTableWithZone(NSHashTable *table, NSZone *zone)
/** /**
* Returns the number of items in the table. * Returns the number of items in the table.
*/ */
unsigned int NSUInteger
NSCountHashTable(NSHashTable *table) NSCountHashTable(NSHashTable *table)
{ {
return [table count]; return [table count];
@ -275,7 +275,7 @@ NSCountHashTable(NSHashTable *table)
NSHashTable * NSHashTable *
NSCreateHashTable( NSCreateHashTable(
NSHashTableCallBacks callBacks, NSHashTableCallBacks callBacks,
unsigned int capacity) NSUInteger capacity)
{ {
return NSCreateHashTableWithZone(callBacks, capacity, NSDefaultMallocZone()); return NSCreateHashTableWithZone(callBacks, capacity, NSDefaultMallocZone());
} }
@ -292,7 +292,7 @@ NSCreateHashTable(
NSHashTable * NSHashTable *
NSCreateHashTableWithZone( NSCreateHashTableWithZone(
NSHashTableCallBacks k, NSHashTableCallBacks k,
unsigned int capacity, NSUInteger capacity,
NSZone *zone) NSZone *zone)
{ {
GSIMapTable table; GSIMapTable table;
@ -726,7 +726,7 @@ NSStringFromHashTable(NSHashTable *table)
/* These are to increase readabilty locally. */ /* 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 BOOL (*NSHT_isEqual_func_t)(NSHashTable *, const void *, const void *);
typedef void (*NSHT_retain_func_t)(NSHashTable *, const void *); typedef void (*NSHT_retain_func_t)(NSHashTable *, const void *);
typedef void (*NSHT_release_func_t)(NSHashTable *, void *); typedef void (*NSHT_release_func_t)(NSHashTable *, void *);
@ -855,7 +855,7 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks =
- (NSArray*) allObjects - (NSArray*) allObjects
{ {
NSHashEnumerator enumerator; NSHashEnumerator enumerator;
unsigned index; NSUInteger index;
NSArray *a; NSArray *a;
GS_BEGINITEMBUF(objects, nodeCount, id); GS_BEGINITEMBUF(objects, nodeCount, id);

View file

@ -385,7 +385,7 @@ NSCopyMapTableWithZone(NSMapTable *table, NSZone *zone)
/** /**
* Returns the number of key/value pairs in the table. * Returns the number of key/value pairs in the table.
*/ */
unsigned int NSUInteger
NSCountMapTable(NSMapTable *table) NSCountMapTable(NSMapTable *table)
{ {
if (table == nil) if (table == nil)
@ -411,7 +411,7 @@ NSMapTable *
NSCreateMapTable( NSCreateMapTable(
NSMapTableKeyCallBacks keyCallBacks, NSMapTableKeyCallBacks keyCallBacks,
NSMapTableValueCallBacks valueCallBacks, NSMapTableValueCallBacks valueCallBacks,
unsigned int capacity) NSUInteger capacity)
{ {
return NSCreateMapTableWithZone(keyCallBacks, valueCallBacks, return NSCreateMapTableWithZone(keyCallBacks, valueCallBacks,
capacity, NSDefaultMallocZone()); capacity, NSDefaultMallocZone());
@ -430,7 +430,7 @@ NSMapTable *
NSCreateMapTableWithZone( NSCreateMapTableWithZone(
NSMapTableKeyCallBacks k, NSMapTableKeyCallBacks k,
NSMapTableValueCallBacks v, NSMapTableValueCallBacks v,
unsigned int capacity, NSUInteger capacity,
NSZone *zone) NSZone *zone)
{ {
GSIMapTable table; GSIMapTable table;
@ -1002,7 +1002,7 @@ NSStringFromMapTable(NSMapTable *table)
/* These are to increase readabilty locally. */ /* 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 BOOL (*NSMT_is_equal_func_t)(NSMapTable *, const void *, const void *);
typedef void (*NSMT_retain_func_t)(NSMapTable *, const void *); typedef void (*NSMT_retain_func_t)(NSMapTable *, const void *);
typedef void (*NSMT_release_func_t)(NSMapTable *, void *); typedef void (*NSMT_release_func_t)(NSMapTable *, void *);

View file

@ -133,14 +133,16 @@ static Class concreteClass = 0;
- (NSUInteger) count - (NSUInteger) count
{ {
return (NSUInteger)[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
return (NSUInteger)0;
} }
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state - (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
objects: (id*)stackbuf objects: (id*)stackbuf
count: (NSUInteger)len count: (NSUInteger)len
{ {
return (NSUInteger)[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
return (NSUInteger)0;
} }
- (NSDictionary*) dictionaryRepresentation - (NSDictionary*) dictionaryRepresentation
@ -201,7 +203,7 @@ static Class concreteClass = 0;
- (void) removeAllObjects - (void) removeAllObjects
{ {
unsigned count = [self count]; NSUInteger count = [self count];
if (count > 0) if (count > 0)
{ {

View file

@ -2150,7 +2150,7 @@ static Class tcpPortClass;
#endif #endif
{ {
struct sockaddr_in sockAddr; struct sockaddr_in sockAddr;
size_t size = sizeof(sockAddr); socklen_t size = sizeof(sockAddr);
desc = accept(listener, (struct sockaddr*)&sockAddr, &size); desc = accept(listener, (struct sockaddr*)&sockAddr, &size);
if (desc == INVALID_SOCKET) if (desc == INVALID_SOCKET)

62
configure vendored
View file

@ -11372,6 +11372,68 @@ fi
done 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 # These headers/functions needed for stacktrace in NSException.m

View file

@ -802,6 +802,7 @@ fi
# These headers/functions needed by GSTcpPort.m # These headers/functions needed by GSTcpPort.m
#-------------------------------------------------------------------- #--------------------------------------------------------------------
AC_CHECK_HEADERS(sys/socket.h netinet/in.h) AC_CHECK_HEADERS(sys/socket.h netinet/in.h)
AC_CHECK_TYPES([socklen_t])
dnl AC_REPLACE_FUNCS(recvfrom) dnl AC_REPLACE_FUNCS(recvfrom)
#-------------------------------------------------------------------- #--------------------------------------------------------------------