鳳鳴は祖父の俳号

日記 メモ そんなの

GNU APL1.0 MacOSX10.8での作業メモ

GNU APL

 おことわり:こういう作業はド素人です。

MacOSX 10.8だと ./configure後 makeで以下のエラー。

$ make install
Making install in src
Making install in APs
g++ -DHAVE_CONFIG_H -I. -I../.. -I .. -g2 -DAP_NUM=100 -g -O2 -MT AP100-AP100.o -MD -MP -MF .deps/AP100-AP100.Tpo -c -o AP100-AP100.o `test -f 'AP100.cc' || echo './'`AP100.cc
g++ -DHAVE_CONFIG_H -I. -I../.. -I .. -g2 -DAP_NUM=100 -g -O2 -MT AP100-APmain.o -MD -MP -MF .deps/AP100-APmain.Tpo -c -o AP100-APmain.o `test -f 'APmain.cc' || echo './'`APmain.cc
APmain.cc:27:23: error: sys/prctl.h: No such file or directory
In file included from AP100.cc:31:
../CDR_string.hh:24:20: error: endian.h: No such file or directory
In file included from AP100.cc:31:
../CDR_string.hh: In member function ‘int CDR_string::get_ptr() const’:
../CDR_string.hh:78: error: ‘be32toh’ was not declared in this scope
../CDR_string.hh: In member function ‘int CDR_string::get_nb() const’:
../CDR_string.hh:82: error: ‘be32toh’ was not declared in this scope
../CDR_string.hh: In member function ‘int CDR_string::get_nelm() const’:
../CDR_string.hh:87: error: ‘be32toh’ was not declared in this scope
../CDR_string.hh: In member function ‘uint32_t CDR_string::get_4(unsigned int) const’:
../CDR_string.hh:139: error: ‘htobe32’ was not declared in this scope
In file included from APmain.cc:40:
../Svar_signals.hh: In static member function ‘static Signal_base* Signal_base::recv(UdpSocket&, void*, uint16_t&, uint32_t&, uint32_t)’:
../Svar_signals.hh:1206: error: ‘EBADRQC’ was not declared in this scope
In file included from AP100.cc:33:
../Svar_signals.hh: In static member function ‘static Signal_base* Signal_base::recv(UdpSocket&, void*, uint16_t&, uint32_t&, uint32_t)’:
../Svar_signals.hh:1206: error: ‘EBADRQC’ was not declared in this scope
APmain.cc: At global scope:
APmain.cc:187: error: too many initializers for ‘sigaction’
make[2]: *** [AP100-AP100.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [AP100-APmain.o] Error 1
make[1]: *** [install-recursive] Error 1
make: *** [install-recursive] Error 1
$ pwd


 sys/prctl.hとはなんだ?
Man page of PRCTL

PR_SET_NAME (Linux 2.6.9 以降)
呼び出し元プロセスのプロセス名を (char *) arg2 が指す場所に格納された値を使って設定する。 名前は最大で 16 バイトであり、 それより少ないバイト数の場合は NULL で終端すべきである。

 直ちに影響はなさそうな気もするので、コメントアウトしてみるか。
UdpSocket.cc
APs/APmain.cc
のprctlが出る行をコメントアウト

 次はendian.h これはC++で半標準的に使われている、ということらしい。MacOSX用のendian.hは見つかった。
http://www.opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/Endian.h

CDR.hh:#include
CDR_string.hh:#include

Man page of ENDIAN

CDR.hhとCDR_string.hh内のendian.hをarpa/inet.hに書き換え。
be32toh()、htobe32() をntohl()、htonl()に置き換えればいいのかな?
CDR_string.hh の該当箇所を書き換え。

Svar_signals.hh EBADRQCってなんだ?
var_signals.hh: errno = EBADRQC;

定数みたい。
#define EBADRQC 56 /* Invalid request code */
errno = EBADRQC;
#undef EBADRQC

自分でもヒドイと思う。これで続けられるかな。

$ make
make all-recursive
Making all in src
Making all in APs
g++ -DHAVE_CONFIG_H -I. -I../.. -I .. -g2 -DAP_NUM=100 -g -O2 -MT AP100-AP100.o -MD -MP -MF .deps/AP100-AP100.Tpo -c -o AP100-AP100.o `test -f 'AP100.cc' || echo './'`AP100.cc
g++ -DHAVE_CONFIG_H -I. -I../.. -I .. -g2 -DAP_NUM=100 -g -O2 -MT AP100-APmain.o -MD -MP -MF .deps/AP100-APmain.Tpo -c -o AP100-APmain.o `test -f 'APmain.cc' || echo './'`APmain.cc
APmain.cc:187: error: too many initializers for ‘sigaction’
make[3]: *** [AP100-APmain.o] Error 1
make[3]: *** Waiting for unfinished jobs....
mv -f .deps/AP100-AP100.Tpo .deps/AP100-AP100.Po
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
$

APs/APmain.ccの187行目、sigactionの要素数に対し初期値を設定するのが多い、と
sigaction

こう書き換えた。
/// static struct sigaction new_ctl_C_action = { control_C, 0, 0, 0, 0 };
static struct sigaction new_ctl_C_action = { control_C, 0, 0 };


$ make
make all-recursive
Making all in src
Making all in APs
g++ -DHAVE_CONFIG_H -I. -I../.. -I .. -g2 -DAP_NUM=100 -g -O2 -MT AP100-Backtrace.o -MD -MP -MF .deps/AP100-Backtrace.Tpo -c -o AP100-Backtrace.o `test -f '../Backtrace.cc' || echo './'`../Backtrace.cc
g++ -DHAVE_CONFIG_H -I. -I../.. -I .. -g2 -DAP_NUM=210 -g -O2 -MT AP210-AP210.o -MD -MP -MF .deps/AP210-AP210.Tpo -c -o AP210-AP210.o `test -f 'AP210.cc' || echo './'`AP210.cc
AP210.cc:27:23: error: sys/prctl.h: No such file or directory
../Backtrace.cc:26:20: error: malloc.h: No such file or directory
AP210.cc: In function ‘int seek_variable(FILE*, int, int)’:
AP210.cc:149: error: ‘be32toh’ was not declared in this scope
AP210.cc: In function ‘int read_variable(FILE*, int, Coupled_var&, int&, int, int, bool)’:
AP210.cc:189: error: ‘be32toh’ was not declared in this scope
make[3]: *** [AP210-AP210.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [AP100-Backtrace.o] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

AP210.ccもsys/prctl.hを使っている。
be32toh()をntohl()に置き換え。

MacOSXではmalloc.hはmalloc/malloc.hらしいので Backtrace.cc修正。

$ make
make  all-recursive
Making all in src
Making all in APs
g++ -DHAVE_CONFIG_H -I. -I../..    -I .. -g2 -DAP_NUM=100 -g -O2 -MT AP100-Backtrace.o -MD -MP -MF .deps/AP100-Backtrace.Tpo -c -o AP100-Backtrace.o `test -f '../Backtrace.cc' || echo './'`../Backtrace.cc
g++ -DHAVE_CONFIG_H -I. -I../..    -I .. -g2 -DAP_NUM=210 -g -O2 -MT AP210-APmain.o -MD -MP -MF .deps/AP210-APmain.Tpo -c -o AP210-APmain.o `test -f 'APmain.cc' || echo './'`APmain.cc
mv -f .deps/AP100-Backtrace.Tpo .deps/AP100-Backtrace.Po
g++ -DHAVE_CONFIG_H -I. -I../..    -I .. -g2 -DAP_NUM=210 -g -O2 -MT AP210-UdpSocket.o -MD -MP -MF .deps/AP210-UdpSocket.Tpo -c -o AP210-UdpSocket.o `test -f '../UdpSocket.cc' || echo './'`../UdpSocket.cc
../UdpSocket.cc: In constructor ‘UdpSocket::UdpSocket(uint16_t, uint16_t, uint32_t, uint32_t, bool)’:
../UdpSocket.cc:86: warning: comparison is always false due to limited range of data type
mv -f .deps/AP210-APmain.Tpo .deps/AP210-APmain.Po
g++ -DHAVE_CONFIG_H -I. -I../..    -I .. -g2 -DAP_NUM=210 -g -O2 -MT AP210-Svar_DB.o -MD -MP -MF .deps/AP210-Svar_DB.Tpo -c -o AP210-Svar_DB.o `test -f '../Svar_DB.cc' || echo './'`../Svar_DB.cc
mv -f .deps/AP210-UdpSocket.Tpo .deps/AP210-UdpSocket.Po
g++ -DHAVE_CONFIG_H -I. -I../..    -I .. -g2 -DAP_NUM=210 -g -O2 -MT AP210-Backtrace.o -MD -MP -MF .deps/AP210-Backtrace.Tpo -c -o AP210-Backtrace.o `test -f '../Backtrace.cc' || echo './'`../Backtrace.cc
mv -f .deps/AP210-Backtrace.Tpo .deps/AP210-Backtrace.Po
g++ -DHAVE_CONFIG_H -I. -I../..    -I .. -g2 -DAP_NUM=0 -g -O2 -MT APnnn-APnnn.o -MD -MP -MF .deps/APnnn-APnnn.Tpo -c -o APnnn-APnnn.o `test -f 'APnnn.cc' || echo './'`APnnn.cc
APnnn.cc:27:23: error: sys/prctl.h: No such file or directory
mv -f .deps/AP210-Svar_DB.Tpo .deps/AP210-Svar_DB.Po
g++ -DHAVE_CONFIG_H -I. -I../..    -I .. -g2 -DAP_NUM=0 -g -O2 -MT APnnn-APmain.o -MD -MP -MF .deps/APnnn-APmain.Tpo -c -o APnnn-APmain.o `test -f 'APmain.cc' || echo './'`APmain.cc
make[3]: *** [APnnn-APnnn.o] Error 1
make[3]: *** Waiting for unfinished jobs....
mv -f .deps/APnnn-APmain.Tpo .deps/APnnn-APmain.Po
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2


 UdpSocket.ccにwarning出た。とりあえず保留にしてAPs/APnnn.ccのsys/prctl.hを消す。

以下、エラーのところだけ。
In file included from CDR.cc:21:
CDR.hh: In static member function ‘static uint32_t CDR::get_2_be(const uint8_t*)’:
CDR.hh:46: error: ‘htobe16’ was not declared in this scope
CDR.hh: In static member function ‘static uint32_t CDR::get_4_be(const uint8_t*)’:
CDR.hh:50: error: ‘htobe32’ was not declared in this scope
CDR.hh: In static member function ‘static uint64_t CDR::get_8_be(const uint8_t*)’:
CDR.hh:54: error: ‘htobe64’ was not declared in this scope
make[3]: *** [apl-CDR.o] Error 1
make[3]: *** Waiting for unfinished jobs....
mv -f .deps/apl-Bif_OPER1_SCAN.Tpo .deps/apl-Bif_OPER1_SCAN.Po
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

CDR.hh
htobe32()→htonl()、htobe16()→htons()。64bit版がない。
htobe64()とbe64toh()というのはLinuxにあってMacOSXBSDになさそうな感じ。


 どうもGNU APLはLinuxで動くように作られているらしい。とりあえずここまで。