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'). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41421 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
c7e314bba7
commit
af2da315dc
14
headers/private/system/system_revision.h
Normal file
14
headers/private/system/system_revision.h
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>.
|
||||
* 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 */
|
@ -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 @@ const static char *kKernelName = "kernel_" HAIKU_ARCH;
|
||||
|
||||
// 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")));
|
||||
|
||||
|
||||
|
@ -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")));
|
||||
|
||||
|
||||
|
@ -96,6 +96,7 @@ MODE on <build>rm_attrs = 755 ;
|
||||
|
||||
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++) ;
|
||||
|
||||
|
@ -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 @@ main(int argc, const char* const* argv)
|
||||
|
||||
// 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) {
|
||||
|
Loading…
Reference in New Issue
Block a user