Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/src/runtime/Builtin/primIntegerFromWord64.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include "haskell2c.h"
#include "HsFFI.h"

#ifdef PROFILE
static SInfo nodeProfInfo = { "Builtin","Builtin.primIntegerFromWord64","Prelude.Integer"};
#endif

NodePtr primIntegerFromWord64 (HsWord64 i)
{
  NodePtr result;
  C_CHECK(SIZE_INT64);
  if(i==0) {
    result = C_ALLOC(SIZE_ENUM);
    *result = CONSTRW(0,0);
    INIT_PROFINFO(result,&nodeProfInfo)
  } else if ((0<i) && (i<=HS_WORD32_MAX)) {
    result = C_ALLOC(SIZE_INT);
    result[0] = CONSTRW(1,0);
    INIT_PROFINFO(result,&nodeProfInfo)
    result[1+EXTRA] = (HsWord32)i;
  } else {
    result = C_ALLOC(SIZE_INT64);
    result[0] = CONSTRW(2,0);
    INIT_PROFINFO(result,&nodeProfInfo)
    result[1+EXTRA] = (HsWord32)(i&0x00000000ffffffffULL);
    result[2+EXTRA] = (HsWord32)((i&0xffffffff00000000ULL)>>32);
  }
  return (result);
}



Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.