summaryrefslogtreecommitdiff
path: root/navit
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-08-05 17:20:51 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-08-05 17:20:51 +0000
commit298517da097dc49dc3adaf0f8c62d70d5b5d0183 (patch)
tree71b3c2b0cccc3cb6ab5e634acb7659b8df8c7434 /navit
parente047029fe932df094170670eb6f80b5d1a0ad74e (diff)
downloadnavit-298517da097dc49dc3adaf0f8c62d70d5b5d0183.tar.gz
Fix:Build:Better approach for #pragma pack vs __attribute__((packed))
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@4673 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit')
-rw-r--r--navit/file.c18
-rw-r--r--navit/maptool/maptool.c2
-rw-r--r--navit/maptool/misc.c2
-rw-r--r--navit/maptool/zip.c1
-rw-r--r--navit/zipfile.h88
5 files changed, 33 insertions, 78 deletions
diff --git a/navit/file.c b/navit/file.c
index 477cf98e4..2ce235808 100644
--- a/navit/file.c
+++ b/navit/file.c
@@ -45,6 +45,7 @@
#include "item.h"
#include "util.h"
#include "types.h"
+#include "zipfile.h"
#ifdef HAVE_SOCKET
#include <sys/socket.h>
#include <netdb.h>
@@ -78,20 +79,21 @@ static GHashTable *file_name_hash;
static struct cache *file_cache;
-#ifdef _MSC_VER
-#pragma pack(push,1)
-#endif /* _MSC_VER */
+#ifdef HAVE_PRAGMA_PACK
+#pragma pack(push)
+#pragma pack(1)
+#endif
+
struct file_cache_id {
long long offset;
int size;
int file_name_id;
int method;
-#ifndef _MSC_VER
-}__attribute__ ((packed));
-#else /* _MSC_VER */
-};
+} ATTRIBUTE_PACKED;
+
+#ifdef HAVE_PRAGMA_PACK
#pragma pack(pop)
-#endif /* _MSC_VER */
+#endif
#ifdef HAVE_SOCKET
static int
diff --git a/navit/maptool/maptool.c b/navit/maptool/maptool.c
index 065783a99..d8d61bea2 100644
--- a/navit/maptool/maptool.c
+++ b/navit/maptool/maptool.c
@@ -37,9 +37,9 @@
#include "file.h"
#include "item.h"
#include "map.h"
-#include "zipfile.h"
#include "main.h"
#include "config.h"
+#include "zipfile.h"
#include "linguistics.h"
#include "plugin.h"
#include "util.h"
diff --git a/navit/maptool/misc.c b/navit/maptool/misc.c
index 357bdb9b6..5e6c39e74 100644
--- a/navit/maptool/misc.c
+++ b/navit/maptool/misc.c
@@ -36,9 +36,9 @@
#include "file.h"
#include "item.h"
#include "map.h"
-#include "zipfile.h"
#include "main.h"
#include "config.h"
+#include "zipfile.h"
#include "linguistics.h"
#include "plugin.h"
#include "maptool.h"
diff --git a/navit/maptool/zip.c b/navit/maptool/zip.c
index c8782a55b..578f356eb 100644
--- a/navit/maptool/zip.c
+++ b/navit/maptool/zip.c
@@ -21,6 +21,7 @@
#include <string.h>
#include <stdlib.h>
#include "maptool.h"
+#include "config.h"
#include "zipfile.h"
#ifdef HAVE_LIBCRYPTO
diff --git a/navit/zipfile.h b/navit/zipfile.h
index bb08760a6..0847dbba7 100644
--- a/navit/zipfile.h
+++ b/navit/zipfile.h
@@ -18,12 +18,19 @@
*/
#ifndef __ZIPFILE_H__
-#ifdef HAVE_API_WIN32_CE
-/* cegcc doesn't honor the __attribute__(packed) need pragma to work */
+#define __ZIPFILE_H__
+
+#ifdef HAVE_PRAGMA_PACK
#pragma pack(push)
#pragma pack(1)
#endif
+#ifdef __GNUC__
+#define ATTRIBUTE_PACKED __attribute__ ((packed))
+#else
+#define ATTRIBUTE_PACKED
+#endif
+
#define zip_split_sig 0x08074b50
struct zip_split {
@@ -32,9 +39,6 @@ struct zip_split {
#define zip_lfh_sig 0x04034b50
-#ifdef _MSC_VER
-#pragma pack(push,1)
-#endif /* _MSC_VER */
struct zip_lfh {
int ziplocsig;
short zipver; // 4
@@ -48,18 +52,10 @@ struct zip_lfh {
unsigned short zipfnln; // 26
unsigned short zipxtraln; // 30
char zipname[0]; // 34
-#ifndef _MSC_VER
-}__attribute__ ((packed));
-#else /* _MSC_VER */
-};
-#pragma pack(pop)
-#endif /* _MSC_VER */
+} ATTRIBUTE_PACKED;
#define zip_cd_sig 0x02014b50
-#ifdef _MSC_VER
-#pragma pack(push,1)
-#endif /* _MSC_VER */
struct zip_cd {
int zipcensig;
char zipcver;
@@ -81,31 +77,14 @@ struct zip_cd {
unsigned int zipext;
unsigned int zipofst;
char zipcfn[0];
-#ifndef _MSC_VER
-}__attribute__ ((packed));
-#else /* _MSC_VER */
-};
-#pragma pack(pop)
-#endif /* _MSC_VER */
-
+} ATTRIBUTE_PACKED;
-#ifdef _MSC_VER
-#pragma pack(push,1)
-#endif /* _MSC_VER */
struct zip_cd_ext {
short tag;
short size;
unsigned long long zipofst;
-#ifndef _MSC_VER
-}__attribute__ ((packed));
-#else /* _MSC_VER */
-};
-#pragma pack(pop)
-#endif /* _MSC_VER */
+} ATTRIBUTE_PACKED;
-#ifdef _MSC_VER
-#pragma pack(push,1)
-#endif /* _MSC_VER */
struct zip_enc {
short efield_header;
short efield_size;
@@ -113,18 +92,10 @@ struct zip_enc {
char vendor_id1,vendor_id2;
char encryption_strength;
short compress_method;
-#ifndef _MSC_VER
-}__attribute__ ((packed));
-#else /* _MSC_VER */
-};
-#pragma pack(pop)
-#endif /* _MSC_VER */
+} ATTRIBUTE_PACKED;
#define zip_eoc_sig 0x6054b50
-#ifdef _MSC_VER
-#pragma pack(push,1)
-#endif /* _MSC_VER */
struct zip_eoc {
int zipesig; /* end of central dir signature */
unsigned short zipedsk; /* number of this disk */
@@ -135,18 +106,10 @@ struct zip_eoc {
unsigned int zipeofst; /* offset of start of central directory with respect to the starting disk number */
short zipecoml; /* .ZIP file comment length */
char zipecom[0]; /* .ZIP file comment */
-#ifndef _MSC_VER
-}__attribute__ ((packed));
-#else /* _MSC_VER */
-};
-#pragma pack(pop)
-#endif /* _MSC_VER */
+} ATTRIBUTE_PACKED;
#define zip64_eoc_sig 0x6064b50
-#ifdef _MSC_VER
-#pragma pack(push,1)
-#endif /* _MSC_VER */
struct zip64_eoc {
int zip64esig; /* zip64 end of central dir signature */
unsigned long long zip64esize; /* size of zip64 end of central directory record */
@@ -159,33 +122,22 @@ struct zip64_eoc {
unsigned long long zip64ecsz; /* size of the central directory */
unsigned long long zip64eofst; /* offset of start of central directory with respect to the starting disk number */
char zip64ecom[0]; /* zip64 extensible data sector */
-#ifndef _MSC_VER
-}__attribute__ ((packed));
-#else /* _MSC_VER */
-};
-#pragma pack(pop)
-#endif /* _MSC_VER */
+} ATTRIBUTE_PACKED;
#define zip64_eocl_sig 0x07064b50
-#ifdef _MSC_VER
-#pragma pack(push,1)
-#endif /* _MSC_VER */
struct zip64_eocl {
int zip64lsig;
int zip64ldsk;
long long zip64lofst;
int zip74lnum;
-#ifndef _MSC_VER
-}__attribute__ ((packed));
-#else /* _MSC_VER */
+} ATTRIBUTE_PACKED;
+
+struct zip_alignment_check {
+ int x[sizeof(struct zip_cd) == 46 ? 1:-1];
};
-#pragma pack(pop)
-#endif /* _MSC_VER */
-#define __ZIPFILE_H__
-#ifdef __CEGCC__
+#ifdef HAVE_PRAGMA_PACK
#pragma pack(pop)
#endif
-
#endif