Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/src/runtime/Builtin/primIntegerToWord64.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.primIntegerToWord64","Prelude.Word64"};
#endif

HsWord64 primIntegerToWord64 (NodePtr integer)
{
  Int tag,size;
  HsWord64 result;
  tag = *integer;
  size = CONINFO_LARGESIZEU(tag);
  if(!size) {
    result = 0;
  } else if (size==1) {
    result = (HsWord64)integer[1+EXTRA];
  } else if (size==2) {
    result = (HsWord64)integer[1+EXTRA]+((HsWord64)integer[2+EXTRA]<<32);
  } else {
     fprintf(stderr,"Warning: fromInteger truncates value to fit Word64\n");
  }
  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.