2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #ifndef __NGExtensions_common_h__
23 #define __NGExtensions_common_h__
25 #import <Foundation/Foundation.h>
26 #import <Foundation/NSMapTable.h>
28 #include <NGExtensions/AutoDefines.h>
32 #elif defined(NeXT) || NeXT_Foundation_LIBRARY
33 # include <netinet/in.h>
35 # include <arpa/inet.h>
43 # import <objc/objc-api.h>
44 # import <objc/objc.h>
45 # import <objc/encoding.h>
48 #if LIB_FOUNDATION_LIBRARY
50 # import <extensions/objc-runtime.h>
54 # define ASSIGN(object, value) \
55 ({id __object = (id)object; \
56 id __value = (id)value; \
57 if (__value != __object) { if (__value) [__value retain]; \
58 if (__object) [__object release]; \
62 # define ASSIGNCOPY(object, value) \
63 ({id __object = (id)object; \
64 id __value = (id)value; \
65 if (__value != __object) { if (__value) __value = [__value copy]; \
66 if (__object) [__object release]; \
70 #if LIB_FOUNDATION_LIBRARY
87 static inline const char *index(const char *str, char c) __attribute__((unused));
89 static const char *index(const char *str, char c) {
90 while ((*str != '\0') && (*str != c)) str++;
91 if (*str == '\0') return NULL;
97 # define BEGIN_PROFILE \
98 { NSTimeInterval __ti = [[NSDate date] timeIntervalSince1970];
100 # define END_PROFILE \
101 __ti = [[NSDate date] timeIntervalSince1970] - __ti;\
103 printf("***PROF[%s]: %0.3fs\n", __PRETTY_FUNCTION__, __ti);\
104 else if (__ti > 0.005) \
105 printf("PROF[%s]: %0.3fs\n", __PRETTY_FUNCTION__, __ti);\
108 # define PROFILE_CHECKPOINT(__key__) \
109 printf("---PROF[%s] CP %s: %0.3fs\n", __PRETTY_FUNCTION__, __key__,\
110 [[NSDate date] timeIntervalSince1970] - __ti)
113 # define BEGIN_PROFILE {
114 # define END_PROFILE }
115 # define PROFILE_CHECKPOINT(__key__)