{"thread":{"id":"37459","subject":"progress.c does not compile under Mac OS X","startedAt":"2014-08-30T20:37:00Z","lastAt":"2014-08-30T23:12:31Z","messageCount":2,"participants":["Torsten Bögershausen","Jonas 'Sortie' Termansen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"248659","messageId":"540235EC.2020303@web.de","threadId":"37459","inReplyTo":null,"subject":"progress.c does not compile under Mac OS X","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2014-08-30T20:37:00Z","receivedAt":"2014-08-30T20:37:00Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"progress.c:66: error: ‘CLOCK_MONOTONIC’ undeclared (first use in this function)\n\nYou can not cast a undeclared into void in git-compat-uitl.h:\n#define timer_create(clockid, sevp, timerp) ((void) (clockid), (void) (sevp), (void) (timerp), errno \n\n\nRemoving the cast of a define into (void) makes the compilation error in line 66 go away:\n #ifdef NO_TIMER_SETTIME\n-#define timer_create(clockid, sevp, timerp) ((void) (clockid), (void) (sevp), (void) (timerp), errno = ENOSYS, -1)\n+#define timer_create(clockid, sevp, timerp) ((void) (sevp), (void) (timerp), errno = ENOSYS, -1)\n \nBut now we have a bunch of other problems:\n\nprogress.c:71: warning: assignment makes integer from pointer without a cast\nprogress.c:71: error: invalid operands to binary / (have ‘long int *’ and ‘long int’)\nprogress.c:71: warning: statement with no effect\nprogress.c:71: error: ‘_ivalue_it_value’ undeclared (first use in this function)\nprogress.c:71: error: (Each undeclared identifier is reported only once\nprogress.c:71: error: for each function it appears in.)\nprogress.c:71: error: invalid operands to binary / (have ‘long int *’ and ‘long int’)\nprogress.c:74: error: expected ‘while’ before ‘static’\nprogress.c:82: error: nested functions are disabled, use -fnested-functions to re-enable\nprogress.c:82: error: invalid storage class for function ‘display’\nprogress.c: In function ‘display’:\nprogress.c:92: warning: implicit declaration of function ‘clear_progress_signal’\nprogress.c: In function ‘set_progress_signal’:\nprogress.c:126: error: nested functions are disabled, use -fnested-functions to re-enable\nprogress.c:126: error: invalid storage class for function ‘throughput_string’\nprogress.c:135: error: nested functions are disabled, use -fnested-functions to re-enable\nprogress.c:199: error: nested functions are disabled, use -fnested-functions to re-enable\nprogress.c:205: error: nested functions are disabled, use -fnested-functions to re-enable\nprogress.c:225: error: nested functions are disabled, use -fnested-functions to re-enable\nprogress.c:230: error: nested functions are disabled, use -fnested-functions to re-enable\nprogress.c:235: error: nested functions are disabled, use -fnested-functions to re-enable\nprogress.c:264: error: expected declaration or statement at end of input\n\n\n----------------\nAnd then we have the question why we do not check the return value of timer_create() in progress.c#66:\n\ntimer_create(CLOCK_MONOTONIC, &sev, &progress_timer);\n\nvalue.it_interval.tv_sec = 1;\nvalue.it_interval.tv_nsec = 0;\nvalue.it_value = value.it_interval;\ntimer_settime(progress_timer, 0, &value, NULL);\n--------------\nShould it be something like this ?\nif (!timer_create(CLOCK_MONOTONIC, &sev, &progress_timer)) {\n  value.it_interval.tv_sec = 1;\n  value.it_interval.tv_nsec = 0;\n  value.it_value = value.it_interval;\n  timer_settime(progress_timer, 0, &value, NULL);\n}\n\n(And possibly more changes to handle errors when calling\ntimer_delete(progress_timer)\n\n\n(Sorry, no, I don't have a patch at hand.\n It feels as if the macros in git-compat-util.h could be converted into real functions,\n in compat/timer_settime.c (or so) so that we can test-compile under Linux)\n"},{"id":"248669","messageId":"54025A5F.1030602@Maxsi.org","threadId":"37459","inReplyTo":"540235EC.2020303@web.de","subject":"Re: progress.c does not compile under Mac OS X","fromName":"Jonas 'Sortie' Termansen","fromEmail":"sortie@maxsi.org","sentAt":"2014-08-30T23:12:31Z","receivedAt":"2014-08-30T23:12:31Z","isPatch":false,"sender":{"key":"sortie@maxsi.org","avatar":"https://avatars.githubusercontent.com/u/3636196?v=4"},"body":"Oh,\n\nI'm a bit confused here - lots of things happening. Submitting patches to\nprojects is usually fairly simple; it's excitingly fresh to get a bunch of\nreplies, having the patch set revised, more replies, then a further revised\npatch set gets merged to a development branch, and then I get suddenly get\nemails about breaking the build on OS X. Let's see if I can figure this out. :-)\n\nMy original patch had a minor bug where it forgot to compatibility-wrap the\nCLOCK_MONOTONIC constant. Surprisingly, it turns out even in 2014 OS X doesn't\nhave the clock_gettime interface. What a silly operating system.\n\nJacob Keller revised my patch set and added compatibility macros that emulate\ntimer_foo using setitimer. Turns out, it had a few typos of its own.\n\nThe revised patch set got slightly changed and was merged to the pu branch,\nwhich is where you are having build trouble now.\n\nAlright, so to recover, first appropriately add this to git-compat-util.h:\n\n+#ifndef CLOCK_MOTOTONIC\n+#define CLOCK_MONOTONIC 1 /* dummy */\n+#define\n\nSecondly, there is a typo where an underscore is used instead of a period.\n\n-       _ivalue_it_value.tv_usec = value.it_value.tv_nsec / 1000L;              \\\n+       _ivalue.it_value.tv_usec = value.it_value.tv_nsec / 1000L;              \\\n\nThird, there needs to be an end brace before the while:\n\n-while (0)\n+} while (0)\n\nThat should fix the immediate breakage, I believe.\n\nLooking closer, there are a bunch of additional issues here:\n\n+#define timer_create(clockid, sevp, timerp) ((void) (clockid), (void) (sevp), (void) (timerp), errno = ENOSYS, -1)\n+#define timer_create(clockid, sevp, timerp) ((void) (clockid), (void) (sevp), (void) (timerp), 0)\n\nThis emulates a timer_create that always fails. That's not what we are trying to\ndo, we want to emulate one that always works. It should return 0 instead of\nsetting errno to ENOSYS and returning -1. (My original patch set made the\nreplacement timer_create this this way, but at that time I was not trying to\nemulate the interface, just stub it.)\n\nFinally patch set also fails to break with platforms with a broken timer_settime\nbut a working setitimer. If that is something we want to support? Might as well.\n\nOn 08/30/2014 10:37 PM, Torsten Bögershausen wrote:\n> And then we have the question why we do not check the return value of\n> timer_create() in progress.c#66:\n\nIt's because the old code didn't check the result value. Secondly it's because\nthis code is non-essential, if it fails, there is really no choice but to carry\non anyways. I admit it's probably not a good idea to make timer_settime time\nwith an uninitialized timer id. The likelihood is low though as git only needs\none timer - but I agree it's prudent to check the error codes.\n\nOn 08/30/2014 10:37 PM, Torsten Bögershausen wrote:\n> It feels as if the macros in git-compat-util.h could be converted into real\n> functions, in compat/timer_settime.c (or so) so that we can test-compile under\n> Linux)\n\nThis is my preferred route as well.\n\nI hope that sorts things out. I'll be submitting a full V2 of my patch set\nshortly that should work reliably on all systems. For now, you can fix the build\nby applying the above fixes, or perhaps revert the commits as they are\ntroublesome. :-)\n\nJonas\n"}]}