[Gptfdisk-general] compiling on openbsd
Brought to you by:
srs5694
From: Joel R. <joe...@gm...> - 2015-10-21 03:26:03
|
Trying to compile gpt-fdisk on openbsd. in guid.h, we have --------------- // Have to play games with uuid_t since it's defined in incompatible ways // for Unix (libuuid) vs. Windows (in rpc.h) #ifdef _WIN32 #include <rpc.h> #ifdef _MSC_VER #pragma comment(lib, "Rpcrt4.lib") #endif typedef unsigned char my_uuid_t[16]; #else // Not Windows #if defined (__OpenBSD__) #include <sys/uuid.h> // maybe it should be uuid.h? (JMRees) typedef uuid_t my_uuid_t[1]; #else #include <uuid/uuid.h> typedef uuid_t my_uuid_t; #endif #endif --------------- However, in openbsd, in sys/uuid.h, we have struct uuid { uint32_t time_low; uint16_t time_mid; uint16_t time_hi_and_version; uint8_t clock_seq_hi_and_reserved; uint8_t clock_seq_low; uint8_t node[_UUID_NODE_LEN]; }; and (since this isn't kernel) typedef struct uuid uuid_t; For a lark, I tried this in guid.h: --------------- #else // Not Windows #if defined (__OpenBSD__) #include <sys/uuid.h> // maybe it should be uuid.h? (JMRees) typedef uuid_t my_uuid_t[1]; #else #include <uuid/uuid.h> typedef uuid_t my_uuid_t; #endif #endif --------------- but that contradicts usage in guid.cc in a number of places which seem to expect an array of bytes. Extending the MSWindows hack to openbsd does allow compiling to proceed a bit farther, ---------------- $ make g++ -O2 -pipe -Wall -D_FILE_OFFSET_BITS=64 -c crc32.cc g++ -O2 -pipe -Wall -D_FILE_OFFSET_BITS=64 -c support.cc g++ -O2 -pipe -Wall -D_FILE_OFFSET_BITS=64 -c guid.cc g++ -O2 -pipe -Wall -D_FILE_OFFSET_BITS=64 -c gptpart.cc g++ -O2 -pipe -Wall -D_FILE_OFFSET_BITS=64 -c mbrpart.cc g++ -O2 -pipe -Wall -D_FILE_OFFSET_BITS=64 -c basicmbr.cc g++ -O2 -pipe -Wall -D_FILE_OFFSET_BITS=64 -c mbr.cc g++ -O2 -pipe -Wall -D_FILE_OFFSET_BITS=64 -c gpt.cc g++ -O2 -pipe -Wall -D_FILE_OFFSET_BITS=64 -c bsd.cc g++ -O2 -pipe -Wall -D_FILE_OFFSET_BITS=64 -c parttypes.cc g++ -O2 -pipe -Wall -D_FILE_OFFSET_BITS=64 -c attributes.cc g++ -O2 -pipe -Wall -D_FILE_OFFSET_BITS=64 -c diskio.cc g++ -O2 -pipe -Wall -D_FILE_OFFSET_BITS=64 -c diskio-unix.cc diskio-unix.cc: In member function 'int DiskIO::DiskSync()': diskio-unix.cc:222: warning: unused variable 'i' diskio-unix.cc: In member function 'int DiskIO::Seek(uint64_t)': diskio-unix.cc:285: error: 'lseek64' was not declared in this scope *** Error 1 in /home/family/work/sf/gptfdisk-code (<sys.mk>:97 'diskio-unix.o') ---------------- but it really wants some kind of compile-time check, or at least a run-time check. Any thoughts? -- Joel Rees Be careful when you look at conspiracy. Arm yourself with knowledge of yourself, as well: http://reiisi.blogspot.jp/2011/10/conspiracy-theories.html ============ $ git diff diff --git a/diskio.h b/diskio.h index 631a43a..c198f29 100644 --- a/diskio.h +++ b/diskio.h @@ -29,7 +29,7 @@ #include <sys/dkio.h> #endif -#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__) +#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__OpenBSD__) || defined (__APPLE__) #define fstat64 fstat #define stat64 stat #endif diff --git a/guid.h b/guid.h index 229d5bd..9210af5 100644 --- a/guid.h +++ b/guid.h @@ -26,8 +26,14 @@ #endif typedef unsigned char my_uuid_t[16]; #else // Not Windows + #if defined (__OpenBSD__) +#include <sys/uuid.h> // maybe it should be uuid.h? (JMRees) +//typedef uuid_t my_uuid_t[1]; +typedef unsigned char my_uuid_t[16]; + #else #include <uuid/uuid.h> typedef uuid_t my_uuid_t; + #endif #endif using namespace std; |