Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefinition of __int64_t and __uint64_t for i386 #7

Open
wargio opened this issue Nov 17, 2013 · 4 comments
Open

Redefinition of __int64_t and __uint64_t for i386 #7

wargio opened this issue Nov 17, 2013 · 4 comments

Comments

@wargio
Copy link

wargio commented Nov 17, 2013

There is a problem when compiling it. i got a redefinition of of __int64_t and __uint64_t

    typedef long long       __int64_t;
    typedef unsigned long long  __uint64_t;

my suggestion is to change them to

    typedef signed long int     __int64_t;
    typedef unsigned long int   __uint64_t;

in this way it compiles and do not say anything since the definition is the same as on linux

@winocm
Copy link
Contributor

winocm commented Nov 17, 2013

long int is 64-bit on LP64, but is 32-bit on !LP64.

long long is correct.

@b-man
Copy link
Owner

b-man commented Nov 17, 2013

wargio, are you on a 64-bit system? Could you give me your build log where the error occurred?

@wargio
Copy link
Author

wargio commented Nov 17, 2013

yes i am.
Linux Linux 3.8.0-33-generic #48-Ubuntu SMP Wed Oct 23 09:16:58 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

as you asked b-man

make[1]: Entering directory `/home/rms/xnu-deps-linux/kext-tools/setsegname'
clang -g -O0 -I ../../include/   -c -o setsegname.o setsegname.c
In file included from setsegname.c:40:
In file included from ../../include/mach-o/swap.h:27:
In file included from ../../include/architecture/byte_order.h:38:
In file included from ../../include/libkern/OSByteOrder.h:33:
In file included from ../../include/libkern/_OSByteOrder.h:40:
In file included from ../../include/sys/_types.h:33:
In file included from ../../include/machine/_types.h:34:
../../include/i386/_types.h:46:20: error: typedef redefinition with different types ('long long' vs 'long')
typedef long long               __int64_t;
                            ^
/usr/include/x86_64-linux-gnu/bits/types.h:43:25: note: previous definition is here
typedef signed long int __int64_t;
                    ^
In file included from setsegname.c:40:
In file included from ../../include/mach-o/swap.h:27:
In file included from ../../include/architecture/byte_order.h:38:
In file included from ../../include/libkern/OSByteOrder.h:33:
In file included from ../../include/libkern/_OSByteOrder.h:40:
In file included from ../../include/sys/_types.h:33:
In file included from ../../include/machine/_types.h:34:
../../include/i386/_types.h:47:28: error: typedef redefinition with different types ('unsigned long long' vs 'unsigned long')
typedef unsigned long long      __uint64_t;
                            ^
/usr/include/x86_64-linux-gnu/bits/types.h:44:27: note: previous definition is here
typedef unsigned long int __uint64_t;
                      ^
2 errors generated.
make[1]: *** [setsegname.o] Error 1
make[1]: Leaving directory `/home/rms/xnu-deps-linux/kext-tools/setsegname'
make: *** [all] Error 2

@b-man
Copy link
Owner

b-man commented Nov 17, 2013

Hmm, it looks like the current set of headers tries to use i386 (32-bit) types and defines even when building on a 64-bit host. I'll add the x86_64 headers and try to have all targets use build host provided machine types (where possible) to avoid name clashes and incompatible types. (I can't get this done today, but I'll try to get it done sometime this week).

For now, I'd recommend replacing the size types in xnu-deps-linux/include/i386/_types.h with the following:

#if defined(__x86_64__) && defined(__linux__)

/* We are running 64-bit linux, use local size types */
#include <sys/types.h>

#ifndef __int8_t
typedef int8_t __int8_t;
#endif

#ifndef __uint8_t
typedef uint8_t __uint8_t;
#endif

#ifndef __int16_t
typedef int16_t __int16_t;
#endif

#ifndef __uint16_t
typedef uint16_t __uint16_t;
#endif

#ifndef __int32_t
typedef int32_t __int32_t;
#endif

#ifndef __uint32_t
typedef uint32_t __uint32_t;
#endif

#ifndef __int64_t 
typedef int64_t __int64_t;
#endif

#ifndef __uint64_t
typedef uint64_t __uint64_t;
#endif

#else

#ifdef __GNUC__
typedef __signed char                __int8_t;
#else        /* !__GNUC__ */
typedef char                        __int8_t;
#endif        /* !__GNUC__ */
typedef unsigned char                __uint8_t;
typedef        short                        __int16_t;
typedef        unsigned short                __uint16_t;
typedef int                        __int32_t;
typedef unsigned int                __uint32_t;
typedef long long                 __int64_t;
typedef unsigned long long        __uint64_t;

#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants