Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

OpenLibm working on 16-bit 8086

オープン
#259 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
28/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
c

調査の方向性

提供された ELKS および ia16-elf-gcc のコンテキストと併せて、src/fpmath.h、src/i386_fpmath.h、src/math_private.h を確認してください。既存の整数幅とビットフィールドに関する前提を確認し、その後 16 ビットターゲット向けにライブラリをビルドまたはテストしてください。既存のレイアウトを壊さずに移植性の問題が解決されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Hello all,

I'm not sure whether anyone is interested in this, but I have successfully ported a number of the OpenLibm math routines to ELKS, an 8086-based Linux kernel and C library, using the ia16-elf-gcc compiler. In this system, int is 16 bits, and long 32 bits. float and double are IEEE 754 32 and 64 bits.

The following patch was required. It may (or may not) be a good idea to consider changing the non-portable unsigned int definitions to something like uint32_t for portability. Not knowing this library well, I am unsure whether unsigned int may need to be 64 bits on some systems, in which case, this would not work. However, it seems the IEEEf2bits structure assumes unsigned int to be 32 bits for its bitfield definitions.

diff --git a/src/fpmath.h b/src/fpmath.h
index 6c37595..5843386 100644
--- a/src/fpmath.h
+++ b/src/fpmath.h
@@ -83,13 +83,13 @@ union IEEEf2bits {
        float   f;
        struct {
 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-               unsigned int    man     :23;
-               unsigned int    exp     :8;
-               unsigned int    sign    :1;
+               unsigned long   man     :23;
+               unsigned long   exp     :8;
+               unsigned long   sign    :1;
 #else /* _BIG_ENDIAN */
-               unsigned int    sign    :1;
-               unsigned int    exp     :8;
-               unsigned int    man     :23;
+               unsigned long   sign    :1;
+               unsigned long   exp     :8;
+               unsigned long   man     :23;
 #endif
        } bits;
 };
@@ -102,19 +102,19 @@ union IEEEd2bits {
        struct {
 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #if __FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__
-               unsigned int    manl    :32;
+               unsigned long   manl    :32;
 #endif
-               unsigned int    manh    :20;
-               unsigned int    exp     :11;
-               unsigned int    sign    :1;
+               unsigned long   manh    :20;
+               unsigned long   exp     :11;
+               unsigned long   sign    :1;
 #if __FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__
-               unsigned int    manl    :32;
+               unsigned long   manl    :32;
 #endif
 #else /* _BIG_ENDIAN */
-               unsigned int    sign    :1;
-               unsigned int    exp     :11;
-               unsigned int    manh    :20;
-               unsigned int    manl    :32;
+               unsigned long   sign    :1;
+               unsigned long   exp     :11;
+               unsigned long   manh    :20;
+               unsigned long   manl    :32;
 #endif
        } bits;
 };
diff --git a/src/i386_fpmath.h b/src/i386_fpmath.h
index 455631c..8b29e38 100644
--- a/src/i386_fpmath.h
+++ b/src/i386_fpmath.h
@@ -29,16 +29,16 @@
 union IEEEl2bits {
        long double     e;
        struct {
-               unsigned int    manl    :32;
-               unsigned int    manh    :32;
-               unsigned int    exp     :15;
-               unsigned int    sign    :1;
-               unsigned int    junk    :16;
+               unsigned long   manl    :32;
+               unsigned long   manh    :32;
+               unsigned long   exp     :15;
+               unsigned long   sign    :1;
+               unsigned long   junk    :16;
        } bits;
        struct {
                unsigned long long man  :64;
-               unsigned int    expsign :16;
-               unsigned int    junk    :16;
+               unsigned long   expsign :16;
+               unsigned long   junk    :16;
        } xbits;
 };
 
diff --git a/src/math_private.h b/src/math_private.h
index 15a27b2..4f7e1d4 100644
--- a/src/math_private.h
+++ b/src/math_private.h
@@ -162,7 +162,7 @@ typedef union
 {
   float value;
   /* FIXME: Assumes 32 bit int.  */
-  unsigned int word;
+  unsigned long word;
 } ieee_float_shape_type;
 
 /* Get a 32 bit int from a float.  */

Thank you!

主要言語
C
スター
637
フォーク
165
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

JuliaMath/openlibm のほかの issue

JuliaMath/openlibm の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。