Determining the platform you are running on

Raimo Niskanen raimo@REDACTED
Fri May 31 09:21:11 CEST 2002


I have solved that particular problem by adding tag to
erlang:system_info/1. Unfortunately does it only exist in (yet to come)
R9. It will be:

6> erlang:system_info(system_architecture).
"i686-pc-linux-gnu"


For the daring open source user I submit two "diff -c"s and a rewritten
utility below. I hope these changes are all it takes.

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



================= diff:
*** erts/emulator/beam/erl_bif_info.c@@/main/release/r9_dev/0   Tue Jan
29 11:21:13 2002
--- erts/emulator/beam/erl_bif_info.c@@/main/release/r9_dev/1   Tue Jan
29 13:51:01 2002
***************
*** 760,766 ****
        n++;
        hp = HAlloc(BIF_P, n*2);
        BIF_RET(buf_to_intlist(&hp, tmp_buf, n, NIL));
!     }
  #ifdef INSTRUMENT
      else if (BIF_ARG_1 == am_allocated) {
        Eterm val;
--- 760,773 ----
        n++;
        hp = HAlloc(BIF_P, n*2);
        BIF_RET(buf_to_intlist(&hp, tmp_buf, n, NIL));
!     } else if (BIF_ARG_1 == am_system_architecture) {
!       int n;
! 
!       sys_strcpy((char*)tmp_buf, ERLANG_ARCHITECTURE);
!       n = sys_strlen((char*)tmp_buf);
!       hp = HAlloc(BIF_P, n*2);
!       BIF_RET(buf_to_intlist(&hp, tmp_buf, n, NIL));
!     } 
  #ifdef INSTRUMENT
      else if (BIF_ARG_1 == am_allocated) {
        Eterm val;
================= diff:
*** erts/emulator/Makefile.in@@/main/release/r9_dev/1   Thu Nov 15
14:06:50 2001
--- erts/emulator/Makefile.in@@/main/release/r9_dev/2   Tue Jan 29
13:50:55 2002
***************
*** 161,167 ****
  
  # version include file
  $(TARGET)/erl_version.h: ../vsn.mk
!       $(PERL) utils/make_version -o $@ $(VSN)$(SERIALNO)
  
  # driver table
  $(TARGET)/driver_tab.c:       Makefile.in
--- 161,167 ----
  
  # version include file
  $(TARGET)/erl_version.h: ../vsn.mk
!       $(PERL) utils/make_version -o $@ $(VSN)$(SERIALNO) $(TARGET)
  
  # driver table
  $(TARGET)/driver_tab.c:       Makefile.in
================= erts/emulator/utils/make_version:
#!/usr/bin/env perl 
# ``The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
# compliance with the License. You should have received a copy of the
# Erlang Public License along with this software. If not, it can be
# retrieved via the world wide web at http://www.erlang.org/.
# 
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
# 
# The Initial Developer of the Original Code is Ericsson Utvecklings AB.
# Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
# AB. All Rights Reserved.''
# 
#     $Id$
#
use strict;

# Create the file erl_version.h
#
# Usage:
#    make_version [ -o outputfile ] version architecture
#
# Output goes to ./erl_version.h (or to "outputfile" if specified)
#

my $time_str   = localtime;
my $outputfile = "erl_version.h";

@ARGV or die "No arguments given to 'make_version'";

if ($ARGV[0] eq '-o') {
  shift;                        # Remove -o
  $outputfile = shift;
  defined $outputfile or die "No output file specified";
}

my $version = shift;
defined $version or die "No version name specified";

my $architecture = shift;
defined $architecture or die "No architecture specified";
$architecture =~ s&^.*[/\\]&&;  # Remove directory part if any

open(FILE, ">$outputfile") or die "Can't create $outputfile: $!";

print FILE <<EOF;
/* This file was created by 'make_version' -- don't modify. */
#define ERLANG_VERSION "$version"
#define ERLANG_COMPILE_DATE "$time_str"
#define ERLANG_ARCHITECTURE "$architecture"
EOF

close(FILE);

exit(0);
================= 






Shawn Pearce wrote:
> 
> Does anyone have any idea on how to request that Erlang return the platform
> it is currently running on?  I'm looking for some type of string, such
> as returned by GNU autoconf's config.guess would return, for example
> "i686-pc-linux-gnu".
> 
> I would like to use this string to determine the name of the directory
> to load my linked-in driver(s) from.
> 
> Or does anyone have a better idea on handling locating my linked in
> driver shared objects?
> 
> --
> Shawn.
> 
> Why do I like Perl?  Because ``in accordance with Unix tradition Perl
> gives you enough rope to hang yourself with.''
> 
> Why do I dislike Java? Because ``the class ROPE that should contain the
> method HANG to do the hanging doesn't exist because there is too much
> 'security' built into the base language.''



More information about the erlang-questions mailing list