# [PATCH 1/2] Make lock local to fetch_pack

8 messages from 2012-12-14 to 2012-12-16. Participants: Matt Kraai, Junio C Hamano, Joachim Schmitz.
Thread: https://gitlist.dev/t/32338

## Matt Kraai, 2012-12-14 18:38

Subject: [PATCH 0/2] Port to QNX
Message-ID: <1355510300-31541-1-git-send-email-kraai@ftbfs.org>
URL: https://gitlist.dev/e/1355510300-31541-1-git-send-email-kraai%40ftbfs.org

```
This series ports Git to QNX.  It builds on both QNX 6.3.2 and QNX
6.5.0.  The test suite does not pass.  Unless the corresponding
software is installed, the following arguments must be passed to Make:

 NO_CURL=1 NO_GETTEXT=1 NO_OPENSSL=1 NO_PERL=1 NO_PYTHON=1 NO_TCLTK=1

  [1/2]: Make lock local to fetch_pack

QNX 6.3.2's unistd.h declares a function named lock, which causes
fetch-pack.c to fail to compile if lock has file-scope.  Since it's
only used in a single function, move it therein.

  [2/2]: Port to QNX

```

## Matt Kraai, 2012-12-14 18:38

Subject: [PATCH 1/2] Make lock local to fetch_pack
Message-ID: <1355510300-31541-2-git-send-email-kraai@ftbfs.org>
URL: https://gitlist.dev/e/1355510300-31541-2-git-send-email-kraai%40ftbfs.org
In-Reply-To: <1355510300-31541-1-git-send-email-kraai@ftbfs.org>

```
From: Matt Kraai <matt.kraai@amo.abbott.com>

lock is only used by fetch_pack, so move it into that function.

Signed-off-by: Matt Kraai <matt.kraai@amo.abbott.com>
---
 fetch-pack.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fetch-pack.c b/fetch-pack.c
index 099ff4d..9d9762d 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -874,8 +874,6 @@ static int fetch_pack_config(const char *var, const char *value, void *cb)
 	return git_default_config(var, value, cb);
 }
 
-static struct lock_file lock;
-
 static void fetch_pack_setup(void)
 {
 	static int did_setup;
@@ -896,6 +894,7 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
 		       struct string_list *sought,
 		       char **pack_lockfile)
 {
+	static struct lock_file lock;
 	struct stat st;
 	struct ref *ref_cpy;
 
-- 
1.8.1-rc1

```

## Matt Kraai, 2012-12-14 18:38

Subject: [PATCH 2/2] Port to QNX
Message-ID: <1355510300-31541-3-git-send-email-kraai@ftbfs.org>
URL: https://gitlist.dev/e/1355510300-31541-3-git-send-email-kraai%40ftbfs.org
In-Reply-To: <1355510300-31541-1-git-send-email-kraai@ftbfs.org>

```
From: Matt Kraai <matt.kraai@amo.abbott.com>

Signed-off-by: Matt Kraai <matt.kraai@amo.abbott.com>
---
 Makefile          | 19 +++++++++++++++++++
 git-compat-util.h |  8 ++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 736ecd4..ed2539d 100644
--- a/Makefile
+++ b/Makefile
@@ -78,6 +78,8 @@ all::
 #
 # Define NO_MEMMEM if you don't have memmem.
 #
+# Define NO_GETPAGESIZE if you don't have getpagesize.
+#
 # Define NO_STRLCPY if you don't have strlcpy.
 #
 # Define NO_STRTOUMAX if you don't have both strtoimax and strtoumax in the
@@ -1448,6 +1450,20 @@ else
 	NO_CURL = YesPlease
 endif
 endif
+ifeq ($(uname_S),QNX)
+	COMPAT_CFLAGS += -DSA_RESTART=0
+	NEEDS_SOCKET = YesPlease
+	NO_MKDTEMP = YesPlease
+	NO_MKSTEMPS = YesPlease
+	NO_FNMATCH_CASEFOLD = YesPlease
+	NO_GETPAGESIZE = YesPlease
+	NO_ICONV = YesPlease
+	NO_MEMMEM = YesPlease
+	NO_NSEC = YesPlease
+	NO_STRCASESTR = YesPlease
+	NO_STRLCPY = YesPlease
+	PTHREAD_LIBS =
+endif
 
 -include config.mak.autogen
 -include config.mak
@@ -1859,6 +1875,9 @@ ifdef NO_MEMMEM
 	COMPAT_CFLAGS += -DNO_MEMMEM
 	COMPAT_OBJS += compat/memmem.o
 endif
+ifdef NO_GETPAGESIZE
+	COMPAT_CFLAGS += -DNO_GETPAGESIZE
+endif
 ifdef INTERNAL_QSORT
 	COMPAT_CFLAGS += -DINTERNAL_QSORT
 	COMPAT_OBJS += compat/qsort.o
diff --git a/git-compat-util.h b/git-compat-util.h
index 2e79b8a..6c588ca 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -75,7 +75,7 @@
 # endif
 #elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && \
       !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__) && \
-      !defined(__TANDEM)
+      !defined(__TANDEM) && !defined(__QNX__)
 #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
 #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
 #endif
@@ -99,7 +99,7 @@
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
-#ifdef __TANDEM /* or HAVE_STRINGS_H or !NO_STRINGS_H? */
+#if defined(__TANDEM) || defined(__QNX__) /* or HAVE_STRINGS_H or !NO_STRINGS_H? */
 #include <strings.h> /* for strcasecmp() */
 #endif
 #include <errno.h>
@@ -411,6 +411,10 @@ void *gitmemmem(const void *haystack, size_t haystacklen,
                 const void *needle, size_t needlelen);
 #endif
 
+#ifdef NO_GETPAGESIZE
+#define getpagesize() sysconf(_SC_PAGESIZE)
+#endif
+
 #ifdef FREAD_READS_DIRECTORIES
 #ifdef fopen
 #undef fopen
-- 
1.8.1-rc1

```

## Junio C Hamano, 2012-12-15 18:38

Subject: Re: [PATCH 0/2] Port to QNX
Message-ID: <7vy5gzrwih.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vy5gzrwih.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1355510300-31541-1-git-send-email-kraai@ftbfs.org>

```
Matt Kraai <kraai@ftbfs.org> writes:

> This series ports Git to QNX.  It builds on both QNX 6.3.2 and QNX
> 6.5.0.  The test suite does not pass.  Unless the corresponding
> software is installed, the following arguments must be passed to Make:
>
>  NO_CURL=1 NO_GETTEXT=1 NO_OPENSSL=1 NO_PERL=1 NO_PYTHON=1 NO_TCLTK=1
>
>   [1/2]: Make lock local to fetch_pack
>
> QNX 6.3.2's unistd.h declares a function named lock, which causes
> fetch-pack.c to fail to compile if lock has file-scope.  Since it's
> only used in a single function, move it therein.
>
>   [2/2]: Port to QNX

I do not mind queuing this on 'pu' but do you want to see your
ftbfs.org address in the commit objects, or the other one that you
are not using to interact with us?

```

## Junio C Hamano, 2012-12-15 18:40

Subject: Re: [PATCH 1/2] Make lock local to fetch_pack
Message-ID: <7vtxrnrwer.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vtxrnrwer.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1355510300-31541-2-git-send-email-kraai@ftbfs.org>

```
Matt Kraai <kraai@ftbfs.org> writes:

> From: Matt Kraai <matt.kraai@amo.abbott.com>
>
> lock is only used by fetch_pack, so move it into that function.
>
> Signed-off-by: Matt Kraai <matt.kraai@amo.abbott.com>
> ---
>  fetch-pack.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Eh, did you base your patch on something older than 2d4177c (Make
fetch-pack a builtin with an internal API, 2007-09-10)???

```

## Junio C Hamano, 2012-12-15 19:31

Subject: Re: [PATCH 1/2] Make lock local to fetch_pack
Message-ID: <7vpq2bru28.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vpq2bru28.fsf%40alter.siamese.dyndns.org
In-Reply-To: <7vtxrnrwer.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

> Matt Kraai <kraai@ftbfs.org> writes:
>
>> From: Matt Kraai <matt.kraai@amo.abbott.com>
>>
>> lock is only used by fetch_pack, so move it into that function.
>>
>> Signed-off-by: Matt Kraai <matt.kraai@amo.abbott.com>
>> ---
>>  fetch-pack.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> Eh, did you base your patch on something older than 2d4177c (Make
> fetch-pack a builtin with an internal API, 2007-09-10)???

Ah, nevermind.  I see we refactored this out recently but that is
still in flight.

```

## Matt Kraai, 2012-12-15 21:55

Subject: Re: [PATCH 0/2] Port to QNX
Message-ID: <20121215215500.GA4257@ftbfs.org>
URL: https://gitlist.dev/e/20121215215500.GA4257%40ftbfs.org
In-Reply-To: <7vy5gzrwih.fsf@alter.siamese.dyndns.org>

```
On Sat, Dec 15, 2012 at 10:38:30AM -0800, Junio C Hamano wrote:
> I do not mind queuing this on 'pu' but do you want to see your
> ftbfs.org address in the commit objects, or the other one that you
> are not using to interact with us?

Great!  I'd prefer to use the amo.abbott.com address in the commit
objects, since that's where I did the work.  I'm using this email
address because it doesn't require figuring out how to send proper
emails via Outlook and/or Exchange.

-- 
Matt

```

## Joachim Schmitz, 2012-12-16 08:27

Subject: Re: [PATCH 2/2] Port to QNX
Message-ID: <kak0kr$cf6$1@ger.gmane.org>
URL: https://gitlist.dev/e/kak0kr%24cf6%241%40ger.gmane.org
In-Reply-To: <1355510300-31541-3-git-send-email-kraai@ftbfs.org>

```
Matt Kraai wrote:
> From: Matt Kraai <matt.kraai@amo.abbott.com>
>
> Signed-off-by: Matt Kraai <matt.kraai@amo.abbott.com>
> ---
> Makefile          | 19 +++++++++++++++++++
> git-compat-util.h |  8 ++++++--
> 2 files changed, 25 insertions(+), 2 deletions(-)
>

snip

> diff --git a/git-compat-util.h b/git-compat-util.h
> index 2e79b8a..6c588ca 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -75,7 +75,7 @@
> # endif
> #elif !defined(__APPLE__) && !defined(__FreeBSD__) &&
>       !defined(__USLC__) && \ !defined(_M_UNIX) && !defined(__sgi) &&
> !defined(__DragonFly__) && \ -      !defined(__TANDEM)
> +      !defined(__TANDEM) && !defined(__QNX__)
> #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD
> needs 600 for S_ISLNK() */ #define _XOPEN_SOURCE_EXTENDED 1 /* AIX
> 5.3L needs this */ #endif
> @@ -99,7 +99,7 @@
> #include <stdlib.h>
> #include <stdarg.h>
> #include <string.h>
> -#ifdef __TANDEM /* or HAVE_STRINGS_H or !NO_STRINGS_H? */
> +#if defined(__TANDEM) || defined(__QNX__) /* or HAVE_STRINGS_H or
> !NO_STRINGS_H? */ #include <strings.h> /* for strcasecmp() */

There's another recent thread, discussing to change this to "#ifdef 
HAVE_STRING_H" plus the infrastructure in Makefile and configure.ac.

Bye, Jojo 

```
