• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
  • Help
    • Online help
    • Learn Git
    • Welcome to Bitbucket
    • Keyboard shortcuts
  • Log In
Alexander Dahl
  1. Alexander Dahl

buildroot

Public
Actions
  • Clone
  • Compare

Learn more about cloning repositories

You have read-only access

Navigation
  • Source
  • Commits
  • Branches
  • All Branches Graph
  • Forks
  1. Alexander Dahl
  2. buildroot

Source

buildroot/package/samba4/samba4-0003-build-find-FILE_OFFSET_BITS-via-array.patch
Gustavo ZacariasGustavo Zacarias committed c94a543137209 May 2014
Raw file
Source viewDiff to previous
xxxxxxxxxx
 
1
From 16d88e7813a7739c070a7a1cf6388fd4f236fd99 Mon Sep 17 00:00:00 2001
2
From: Gustavo Zacarias <gustavo@zacarias.com.ar>
3
Date: Fri, 31 Jan 2014 06:45:18 -0300
4
Subject: [PATCHv2] build: find FILE_OFFSET_BITS via array
5
​
6
This makes cross-compiling happy, use a trick similar to autoconf's
7
AC_CHECK_SIZEOF macro.
8
Basically we make an array:
9
​
10
static int array[1 - 2 * !(((long int)(sizeof(off_t))) < 8)];
11
​
12
This gives -1 multiplied by the negation of the condition
13
(sizeof(off_t) < 8) cast to a long int.
14
So if the condition is true it gives array[(-1 * 0)] (remember the
15
condition is cast and negated) thus passing a build test with a 0-sized
16
array.
17
If it's false it gives array[(-1 * 1)] thus failing with a
18
negative-sized array.
19
​
20
Status: Upstream.
21
​
22
Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
23
---
24
 lib/ccan/wscript | 11 +++++++----
25
 1 file changed, 7 insertions(+), 4 deletions(-)
26
​
27
diff --git a/lib/ccan/wscript b/lib/ccan/wscript
28
index 59b8205..81039d0 100644
29
--- a/lib/ccan/wscript
30
+++ b/lib/ccan/wscript
31
@@ -127,15 +127,18 @@ def configure(conf):
32
     # Only check for FILE_OFFSET_BITS=64 if off_t is normally small:
33
     # use raw routines because wrappers include previous _GNU_SOURCE
34
     # or _FILE_OFFSET_BITS defines.
35
+    # The math for these tests is:
36
+    # array[-1 * !((int)(condition)) ] (condition is true) = array[0] = builds
37
+    # array[-1 * !((int)(condition)) ] (condition is false) = array[-1] = fails
38
     conf.check(fragment="""#include <sys/types.h>
39
-               int main(void) { return !(sizeof(off_t) < 8); }""",
40
-               execute=True, msg='Checking for small off_t',
41
+               int main(void) { static int test_array[1 - 2 * !(((long int)(sizeof(off_t))) < 8)]; }""",
42
+               msg='Checking for small off_t',
43
                define_name='SMALL_OFF_T')
44
     # Unreliable return value above, hence use define.
45
     if conf.CONFIG_SET('SMALL_OFF_T'):
46
         conf.check(fragment="""#include <sys/types.h>
47
-                   int main(void) { return !(sizeof(off_t) >= 8); }""",
48
-                   execute=True, msg='Checking for -D_FILE_OFFSET_BITS=64',
49
+          int main(void) { static int test_array[1 - 2 * !(((long int)(sizeof(off_t))) >= 8)]; }""",
50
+                   msg='Checking for -D_FILE_OFFSET_BITS=64',
51
                    ccflags='-D_FILE_OFFSET_BITS=64',
52
                    define_name='HAVE_FILE_OFFSET_BITS')
53
 
54
-- 
55
1.8.3.2
56
​
  • Git repository management for enterprise teams powered by Atlassian Bitbucket
  • Atlassian Bitbucket v6.7.2
  • Documentation
  • Request a feature
  • About
  • Contact Atlassian
Atlassian

Everything looks good. We'll let you know here if there's anything you should know about.