Author: zooey Date: 2011-05-10 17:35:04 +0200 (Tue, 10 May 2011) New Revision: 41421 Changeset: https://dev.haiku-os.org/changeset/41421 Added: haiku/trunk/headers/private/system/system_revision.h Modified: haiku/trunk/src/system/kernel/system_info.cpp haiku/trunk/src/system/libroot/posix/sys/uname.c haiku/trunk/src/tools/Jamfile haiku/trunk/src/tools/set_haiku_revision.cpp Log: Fix the larger problem that was hiding behind the build problem of set_haiku_revsion on FreeBSD: * the length of the sHaikuRevision character array symbol needs to be set explicitly, as using either _SYS_NAMELEN or sizeof(utsname::version) will only return the values for the host, which may not match ours, thus potentially causing problems when using sHaikuRevision * add headers/private/system_revision.h which defines SYSTEM_REVISION_LENGTH to 128 * adjust definitions of sHaikuRevision in libroot and kernel accordingly utsname::version is shorter than SYSTEM_REVISION_LENGTH, but that doesn't cause any harm until we have indeed switched to a DVCS (in which case longer revision strings will be cut off by 'uname'). Added: haiku/trunk/headers/private/system/system_revision.h =================================================================== --- haiku/trunk/headers/private/system/system_revision.h (rev 0) +++ haiku/trunk/headers/private/system/system_revision.h 2011-05-10 15:35:04 UTC (rev 41421) @@ -0,0 +1,14 @@ +/* + * Copyright 2011, Oliver Tappe <zooey@xxxxxxxxxxxxxxx>. + * Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_SYSTEM_REVISION_H +#define _SYSTEM_SYSTEM_REVISION_H + + +/** The length of the system revision character array symbol living in libroot + and the kernel */ +#define SYSTEM_REVISION_LENGTH 128 + + +#endif /* _SYSTEM_SYSTEM_REVISION_H */ Modified: haiku/trunk/src/system/kernel/system_info.cpp =================================================================== --- haiku/trunk/src/system/kernel/system_info.cpp 2011-05-10 14:40:20 UTC (rev 41420) +++ haiku/trunk/src/system/kernel/system_info.cpp 2011-05-10 15:35:04 UTC (rev 41421) @@ -11,6 +11,7 @@ #include <ksystem_info.h> #include <system_info.h> +#include <system_revision.h> #include <arch/system_info.h> #include <string.h> @@ -31,7 +32,6 @@ #include <real_time_clock.h> #include <sem.h> #include <smp.h> -#include <sys/utsname.h> #include <team.h> #include <thread.h> #include <util/AutoLock.h> @@ -45,7 +45,7 @@ // Haiku SVN revision. Will be set when copying the kernel to the image. // Lives in a separate section so that it can easily be found. -static char sHaikuRevision[_SYS_NAMELEN] +static char sHaikuRevision[SYSTEM_REVISION_LENGTH] __attribute__((section("_haiku_revision"))); Modified: haiku/trunk/src/system/libroot/posix/sys/uname.c =================================================================== --- haiku/trunk/src/system/libroot/posix/sys/uname.c 2011-05-10 14:40:20 UTC (rev 41420) +++ haiku/trunk/src/system/libroot/posix/sys/uname.c 2011-05-10 15:35:04 UTC (rev 41421) @@ -13,10 +13,12 @@ #include <OS.h> +#include <system_revision.h> + // Haiku SVN revision. Will be set when copying libroot.so to the image. // Lives in a separate section so that it can easily be found. -static char sHaikuRevision[_SYS_NAMELEN] +static char sHaikuRevision[SYSTEM_REVISION_LENGTH] __attribute__((section("_haiku_revision"))); Modified: haiku/trunk/src/tools/Jamfile =================================================================== --- haiku/trunk/src/tools/Jamfile 2011-05-10 14:40:20 UTC (rev 41420) +++ haiku/trunk/src/tools/Jamfile 2011-05-10 15:35:04 UTC (rev 41421) @@ -96,6 +96,7 @@ BuildPlatformMain <build>rmattr : rmattr.cpp : $(HOST_LIBBE) ; +UsePrivateObjectHeaders set_haiku_revision : system : : true ; BuildPlatformMain <build>set_haiku_revision : set_haiku_revision.cpp : $(HOST_LIBSTDC++) $(HOST_LIBSUPC++) ; Modified: haiku/trunk/src/tools/set_haiku_revision.cpp =================================================================== --- haiku/trunk/src/tools/set_haiku_revision.cpp 2011-05-10 14:40:20 UTC (rev 41420) +++ haiku/trunk/src/tools/set_haiku_revision.cpp 2011-05-10 15:35:04 UTC (rev 41421) @@ -10,12 +10,13 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/utsname.h> #include <unistd.h> #include <algorithm> #include <string> +#include <system_revision.h> + // We use htonl(), which is defined in <ByteOrder.h> on BeOS R5. #ifdef HAIKU_HOST_PLATFORM_BEOS #include <ByteOrder.h> @@ -585,7 +586,7 @@ // write revision string to section elfObject.Write(info.offset, revisionString, - std::min(sizeof(utsname::version), strlen(revisionString) + 1), + min((size_t)SYSTEM_REVISION_LENGTH, strlen(revisionString) + 1), "Failed to write revision."); } catch (Exception exception) {