Fixes wrong patch introduced for Mac OS X from stackoverflow.

It is for clock_gettime with CLOCK_REALTIME and also changed to use
CLOCK_REALTIME for other than OS X.
Back to use CLOCK_MONOTONIC and use patch for OS X from MacPorts instead.

Bump PKGREVISION.
This commit is contained in:
obache 2014-01-02 08:22:03 +00:00
parent 320986e2eb
commit 23be67a3a5
3 changed files with 30 additions and 80 deletions

View file

@ -1,8 +1,8 @@
# $NetBSD: Makefile,v 1.4 2013/10/31 21:28:07 hubertf Exp $
# $NetBSD: Makefile,v 1.5 2014/01/02 08:22:03 obache Exp $
#
DISTNAME= cogl-1.14.0
PKGREVISION= 3
PKGREVISION= 4
CATEGORIES= graphics
MASTER_SITES= ${MASTER_SITE_GNOME:=sources/cogl/1.14/}
EXTRACT_SUFX= .tar.xz

View file

@ -1,6 +1,6 @@
$NetBSD: distinfo,v 1.2 2013/10/31 21:28:07 hubertf Exp $
$NetBSD: distinfo,v 1.3 2014/01/02 08:22:03 obache Exp $
SHA1 (cogl-1.14.0.tar.xz) = ff9a60b54fe79eb336af9c1b686f71f6af6f84f9
RMD160 (cogl-1.14.0.tar.xz) = 69a87d46c21999bde675a518ab3cbb5dfa159131
Size (cogl-1.14.0.tar.xz) = 1656520 bytes
SHA1 (patch-cogl-winsys-cogl-winsys-glx.c) = fcb293eabeaac7037b77a5f7be0fd3e4e79cccd8
SHA1 (patch-cogl-winsys-cogl-winsys-glx.c) = 865b61bf4926f788548b393dfde1acfa9fb56ce3

View file

@ -1,83 +1,33 @@
$NetBSD: patch-cogl-winsys-cogl-winsys-glx.c,v 1.1 2013/10/31 21:28:07 hubertf Exp $
$NetBSD: patch-cogl-winsys-cogl-winsys-glx.c,v 1.2 2014/01/02 08:22:03 obache Exp $
* for Mac OS X, missing clock_gettime(2), taken from MacPorts.
--- cogl/winsys/cogl-winsys-glx.c.orig 2013-02-21 15:41:08.000000000 +0000
+++ cogl/winsys/cogl-winsys-glx.c
@@ -58,6 +58,12 @@
@@ -56,7 +56,26 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <time.h>
+/* HF: From http://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x */
+#ifdef __MACH__
+#include <mach/clock.h>
+#include <mach/mach.h>
+#endif
+
+#ifdef __MACH__
+#include <mach/mach_time.h>
+#define CLOCK_REALTIME 0
+#define CLOCK_MONOTONIC 0
+static int
+clock_gettime(int clk_id, struct timespec *t){
+ mach_timebase_info_data_t timebase;
+ mach_timebase_info(&timebase);
+ uint64_t time;
+ time = mach_absolute_time();
+ double nseconds = ((double)time * (double)timebase.numer)/((double)timebase.denom);
+ double seconds = ((double)time * (double)timebase.numer)/((double)timebase.denom * 1e9);
+ t->tv_sec = seconds;
+ t->tv_nsec = nseconds;
+ return 0;
+}
+#else
#include <time.h>
+#endif
#include <glib/gi18n-lib.h>
#include <GL/glx.h>
@@ -214,7 +220,20 @@ ensure_ust_type (CoglRenderer *renderer,
/* This is the time source that the newer (fixed) linux drm
* drivers use (Linux >= 3.8) */
- clock_gettime (CLOCK_MONOTONIC, &ts);
+/* HF: From http://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x */
+#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
+ {
+ clock_serv_t cclock;
+ mach_timespec_t mts;
+ host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
+ clock_get_time(cclock, &mts);
+ mach_port_deallocate(mach_task_self(), cclock);
+ ts.tv_sec = mts.tv_sec;
+ ts.tv_nsec = mts.tv_nsec;
+ }
+#else
+ clock_gettime(CLOCK_REALTIME, &ts);
+#endif
current_monotonic_time = (ts.tv_sec * G_GINT64_CONSTANT (1000000)) +
(ts.tv_nsec / G_GINT64_CONSTANT (1000));
@@ -294,7 +313,20 @@ _cogl_winsys_get_clock_time (CoglContext
{
struct timespec ts;
- clock_gettime (CLOCK_MONOTONIC, &ts);
+/* HF: From http://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x */
+#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
+ {
+ clock_serv_t cclock;
+ mach_timespec_t mts;
+ host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
+ clock_get_time(cclock, &mts);
+ mach_port_deallocate(mach_task_self(), cclock);
+ ts.tv_sec = mts.tv_sec;
+ ts.tv_nsec = mts.tv_nsec;
+ }
+#else
+ clock_gettime(CLOCK_REALTIME, &ts);
+#endif
return ts.tv_sec * G_GINT64_CONSTANT (1000000000) + ts.tv_nsec;
}
}
@@ -1500,7 +1532,20 @@ _cogl_winsys_wait_for_vblank (CoglOnscre
(current_count + 1) % 2,
&current_count);
- clock_gettime (CLOCK_MONOTONIC, &ts);
+/* HF: From http://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x */
+#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
+ {
+ clock_serv_t cclock;
+ mach_timespec_t mts;
+ host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
+ clock_get_time(cclock, &mts);
+ mach_port_deallocate(mach_task_self(), cclock);
+ ts.tv_sec = mts.tv_sec;
+ ts.tv_nsec = mts.tv_nsec;
+ }
+#else
+ clock_gettime(CLOCK_REALTIME, &ts);
+#endif
info->presentation_time =
ts.tv_sec * G_GINT64_CONSTANT (1000000000) + ts.tv_nsec;
}