IPv6関係で役立ちそうなところ

2012/01/04memoimport

IPv6関係で役立ちそうなメモ

コンテンツ的に, Linux依りになりそうだけど, まぁ一時待避用という位置づけで...

相手のIPを知りたい

  • 2011/12/21(Wed) 同一セグメントの対向IPv6ホストアドレスを知るライフハック\要約する(?)と、"ff02::1"というglobal IPにたいしてpingを打つといいらしい。\IPv4もデフォルト設定ではWin7マシンがping応答返してくれない模様。ウチのマシンは返しているけど、何かハズしたんだろう. defenderかfirewallかな..? ウイルスバスタ使っていて、ICMP応答は返すにチェックしてあるからだろうなぁ.

[gcc][AVR] attributeによるバイト数装飾

2010/03/11開発環境::gccimport

変数のビットサイズ~gcc方言の巻

avr-gccのstdint.hを見る

VMにWinXP32bitを放り込んで、WinAVR 20100110をインスコ。uint32_tが8bitになっとる、という話をmixiのコミュで見かけたので検証してみました。とりあえずコードレベルで追いかけるとして、ヘッダファイルを探索。

typedef unsigned int uint32_t __attribute__ ((__mode__ (__SI__))); 

・・・・なんぞこれ。

__attribute__ってあたりは、まぁ、なんぞローカル定義の装飾しているなぁとは思うわけですが、__SI__ってなによ...


変数サイズ指定

Anton-sanがいいこといった! Single Integerだそうだ。

・・・ナニソレ?


* Title: Gcc help pages about __mode__ keyword
* From: Anton Soppelsa <soppelsa at igi dot cnr dot it>
* To: gcc at gnu dot org
* Date: Tue, 22 Nov 2005 15:48:45 +0100
* Subject: Gcc help pages about __mode__ keyword

Dear GCC help pages maintainers,
I recently encountered a statement like this one


__attribute__((__mode__(__DI__)))

in a micro kernel source file.

As I'm not so skilled with this kind of C/C++ syntax I tried to read the manual about the keywords involved in that expression.
Despite I found information about "__attribute__" and "__mode__"
I wasn't able to find information about "__DI__" (on the gcc manual pages).
Of course I found in Internet partial explanation of the meaning of "__DI__" keyword and also found out that there are many of the same type like "__SI__", "__HI__", and "__QI__".
 By the way, do they mean Double-, Single-, Half-, Quarter-, -Integer?

The point is that it seem to me those identifiers are actually keywords of the compiler.
So they really have be mentioned (at least) in the compiler manual. Better would be if they are explained.
I guess that part of the manual is not so well maintained because I found only reference to the keywords "__byte__" or "__word__" or "__pointer__".


This message is just to inform u about something if u have the time to work about has to be done (in my opinion) .
Best regards,

※本文にメールアドレスがありましたが、削除しています。改行も入れました..

__SI__の謎

George-sanないすだ!CIL (C Intermediate Language)ということで、Cコンパイル時の中間言語の領域に到達した。やはりこのあたりから学ばないと、コンパイラの理解は終わらないようだな…。


GCC allows you to use the __mode__ attribute to specify the size of the integer instead of the standard char, short and so on:

int __attribute__ ((__mode__ (  __QI__ ))) i8;
int __attribute__ ((__mode__ (  __HI__ ))) i16;
int __attribute__ ((__mode__ (  __SI__ ))) i32;
int __attribute__ ((__mode__ (  __DI__ ))) i64;

ちょっとわかりづらい。CLI特有というわけでもないぽいなぁ...


答えは身近に―

後閑師のところで、C30の説明があり、ここで紹介されてました。ナンテコッタイw

以下、引用

typedef int __attribute__((__mode__(SI))) int32 ; // int32を32ビット幅の整数型と定義

modeで指定したビット幅の型を定義する\byteは1バイト整数型、wordは1ワード整数、pointerはポインタ型を定義する\modeには下記記号が使用できる\QI : 8ビット(char)\HI : 16ビット(int)\SI : 32ビット(long)\DI : 64ビット(long long)\SF : 32ビット(float)\DF : 64ビット(long double)ちょっぴり、アンダースコアの量が違いますが、まぁ、もともとも思想は同じと思って良いでしょう。処理系依存が多いでしょうし、迷ったときはアセンブラコードをはかせてみる。sizeof()でバイト数をチェックする、といった習慣をつけたほうが良いですね。特にマイコン屋さんは。仕事でも趣味でも。ね。。

注意

斜め読みどころか、英語弱いのにかじりながら見た部分が多いですので、鵜呑みにせずリンク先の情報を消化して納得してください。\WEBの情報がすべて正しいとは限りませんし、何事も本家までさかのぼるよう習慣付けましょう…。頼むよほんと(ぉ

[Perl] Win32GuiTest

2009/07/08Perl::MODimport

[Perl] Win32GuiTest

Windows操作を自動化してナニするためのmoduleです。

source codeからのbuildとinstall

まずはソースコードを拾ってきます。本家CPANのWin32::guitestからが良いでしょう。Ver.1.56が取得できます@2009年7月8日現在

サイトからもわかるように、VC++のコマンドラインバッチを走らせた後、下記のscriptを実行して、Makefileを生成させます。

perl makefile.pl

ここで、デフォルトのままですと、VC++のランタイムライブラリ(MSVCRT90.dll(VS2008ExpEdition))が必要になります。Active Perlのversionを合わせておくだけで、ほかのマシンにもmoduleを配るのであれば、ここでstatic linkを選択すべきです。

で、Makefile.PLを編集するのが妥当な気がするのですが、いまいちどうやってコンパイルオプションを引き出してきているのかがわかりませんでした。直接Makefileを編集することにします。

・変更前

CCFLAGS = -nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DUSE_SITECUSTOMIZE -DPRIVLIB_LAST_IN_INC -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX
OPTIMIZE = -MD -Zi -DNDEBUG -O1

LDLOADLIBS =   oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib

・変更後

CCFLAGS = -nologo -GF -W3 -MT -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DUSE_SITECUSTOMIZE -DPRIVLIB_LAST_IN_INC -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX
OPTIMIZE =  -Zi -DNDEBUG -O1

LDLOADLIBS =   oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib libcmt.lib

それぞれ位置はバラバラですが、シンボル名で検索すれば確実でしょう。編集が終わったら、makeします。

nmake

ちんたら文句言われますが、関数宣言してないとかそんなのですね。

実際にstatic linkされたか、dumpbinコマンドで確認しておきましょう。

>dumpbin /dependents blib\arch\auto\Win32\GuiTest\GuiTest.dll

Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file blib\arch\auto\Win32\GuiTest\GuiTest.dll

File Type: DLL

  Image has the following dependencies:

    perl510.dll
    KERNEL32.dll
    USER32.dll
    GDI32.dll

  Summary

        3000 .data
        5000 .rdata
        2000 .reloc
        1000 .rsrc
        1000 .shared
       1B000 .text

VCのdllは要求されていませんね。perlのdllを要求されていることから、少なくとも Perl 5.10以外では使えないことがわかります。Active Perlのversionを合わせておかないと、あとでppm installができません:)

次に、module testを行うわけですが、国際化対応していないのでNGになります。テストパターンは、Win32-GuiTest-1.56\tに入っています。関数電卓(calc)は、メニューやボタン名に漢字が使われるため、windowが見つからないといわれてしまいます。日本語仕様に合わせて修正しておきます。

・"02_calc.t"

#	MenuSelect("&View|&Scientific");
	MenuSelect("表示(&V)|関数電卓(&S)");

#	($hex) = FindWindowLike($calc, "Hex");
	($hex) = FindWindowLike($calc, "16 進");

#	($bin) = FindWindowLike($calc, "Bin");
	($bin) = FindWindowLike($calc, "2 進");

#	($oct) = FindWindowLike($calc, "Oct");
	($oct) = FindWindowLike($calc, "8 進");

#	($dec) = FindWindowLike($calc, "Dec");
	($dec) = FindWindowLike($calc, "10 進");

#	PushButton("Dec"); sleep 1;
	PushButton("10 進"); sleep 1;

#	PushButton("Hex"); sleep 1;
	PushButton("16 進"); sleep 1;

#	PushButton("Oct"); sleep 1;
	PushButton("8 進"); sleep 1;

#	PushButton("Bin"); sleep 1;
	PushButton("2 進"); sleep 1;

・"05_which.t"

# like(WhichExe("progman"),  qr/progman/i,  "progman");

Vista x64環境のせいか、これはスキップされます。

以上でテストはパスされるでしょう。それではインストールしてしまいましょう。

nmake install

配布用パッケージの作成

コマンドラインのzip/tarコマンドなどが必要になります。ない場合は、配布用ディレクトリの作成までで止めておき、windows標準の圧縮フォルダでzipファイルを作るという方法もあります。

nmake ppd
nmake distdir

Win32-GuiTest-1.56というディレクトリができているので、これをzipにします。

次に、Win32-GuiTestを開いて、下記のように修正します。

        <CODEBASE HREF="Win32-GuiTest-1.56.zip" />

ppdとzipとをセットで配布すればおkです。ただしActive perlのDocumentationでブラウズすることができません。htmlは入らない模様です。

使い方

build/install方法を書いてたら時間切れ…。目的を実現する前に力尽きるとは口惜しや・・・('A`


参考