示例#1
1
 /** returns true if the pointer associated with the storage is NULL */
 bool is_null() const {
     void *ptr;
     status_t status = get_data_handle(&ptr);
     assert(status == status::success);
     MAYBE_UNUSED(status);
     return !ptr;
 }
示例#2
0
/*
 * call-seq:
 *   attribute(name)
 *
 * Get the value of attribute named +name+
 */
static VALUE reader_attribute(VALUE self, VALUE name)
{
  xmlTextReaderPtr reader;
  xmlChar *value ;
  Data_Get_Struct(self, xmlTextReader, reader);

  if(name == Qnil) return Qnil;
  name = StringValue(name) ;

  value = xmlTextReaderGetAttribute(reader, (xmlChar*)StringValuePtr(name));
  if(value == NULL) {
    /* this section is an attempt to workaround older versions of libxml that
       don't handle namespaces properly in all attribute-and-friends functions */
    xmlChar *prefix = NULL ;
    xmlChar *localname = xmlSplitQName2((xmlChar*)StringValuePtr(name), &prefix);
    if (localname != NULL) {
      value = xmlTextReaderLookupNamespace(reader, localname);
      xmlFree(localname) ;
    } else {
      value = xmlTextReaderLookupNamespace(reader, prefix);
    }
    xmlFree(prefix);
  }
  if(value == NULL) return Qnil;

  VALUE MAYBE_UNUSED(enc) = rb_iv_get(self, "@encoding");
  VALUE rb_value = NOKOGIRI_STR_NEW2(value,
      RTEST(enc) ? StringValuePtr(enc) : NULL);
  xmlFree(value);
  return rb_value;
}
示例#3
0
 void *data_handle() const {
     void *handle;
     status_t status = get_data_handle(&handle);
     assert(status == status::success);
     MAYBE_UNUSED(status);
     return handle;
 }
示例#4
0
/*
 * call-seq:
 *   name
 *
 * Get the name of the node
 */
static VALUE name(VALUE self)
{
  xmlTextReaderPtr reader;
  Data_Get_Struct(self, xmlTextReader, reader);
  const char * name = (const char *)xmlTextReaderConstName(reader);
  if(name == NULL) return Qnil;

  VALUE MAYBE_UNUSED(enc) = rb_iv_get(self, "@encoding");
  return NOKOGIRI_STR_NEW2(name,
      RTEST(enc) ? StringValuePtr(enc) : NULL);
}
示例#5
0
static void ide_detect_devices(UWORD ifnum)
{
    volatile struct IDE *interface = ide_interface + ifnum;
    struct IFINFO *info = ifinfo + ifnum;
    UBYTE status;
    UWORD signature;
    int i;

    MAYBE_UNUSED(interface);

    IDE_WRITE_CONTROL(IDE_CONTROL_nIEN);    /* no interrupts please */

    /* initial check for devices */
    for (i = 0; i < 2; i++) {
        IDE_WRITE_HEAD(IDE_DEVICE(i));
        DELAY_400NS;
        IDE_WRITE_SECTOR_NUMBER_SECTOR_COUNT(0xaa,0x55);
        IDE_WRITE_SECTOR_NUMBER_SECTOR_COUNT(0x55,0xaa);
        IDE_WRITE_SECTOR_NUMBER_SECTOR_COUNT(0xaa,0x55);
        if (IDE_READ_SECTOR_NUMBER_SECTOR_COUNT() == 0xaa55) {
            info->dev[i].type = DEVTYPE_UNKNOWN;
            KDEBUG(("IDE i/f %d device %d detected\n",ifnum,i));
        } else
            info->dev[i].type = DEVTYPE_NONE;
        info->dev[i].options = 0;
        info->dev[i].spi = 0;   /* changed if using READ/WRITE MULTIPLE */
    }

    /* recheck after soft reset, also detect ata/atapi */
    IDE_WRITE_HEAD(IDE_DEVICE(0));
    DELAY_400NS;
    ide_reset(ifnum);

    for (i = 0; i < 2; i++) {
        IDE_WRITE_HEAD(IDE_DEVICE(i));
        DELAY_400NS;
        if (IDE_READ_SECTOR_NUMBER_SECTOR_COUNT() == 0x0101) {
            status = IDE_READ_STATUS();
            signature = IDE_READ_CYLINDER_HIGH_CYLINDER_LOW();
            info->dev[i].type = ide_decode_type(status,signature);
        }
    }

    for (i = 0; i < 2; i++)
        KDEBUG(("IDE i/f %d device %d is type %d\n",ifnum,i,info->dev[i].type));
}
示例#6
0
/*
 * if multiple mode is set, and ABRT is set in the error register,
 * clear multiple mode and return TRUE to request a retry.
 * otherwise, return FALSE
 */
static WORD clear_multiple_mode(UWORD ifnum,UWORD dev)
{
    volatile struct IDE *interface = ide_interface + ifnum;
    struct IFINFO *info = ifinfo + ifnum;

    MAYBE_UNUSED(interface);

    if ((info->dev[dev].options&MULTIPLE_MODE_ACTIVE) == 0)
        return 0;

    if ((IDE_READ_ERROR()&IDE_ERROR_ABRT) == 0)
        return 0;

    KDEBUG(("Clearing multiple sector mode for ifnum %d dev %d\n",ifnum,dev));

    info->dev[dev].options &= ~MULTIPLE_MODE_ACTIVE;
    return 1;
}
示例#7
0
/*
 * call-seq:
 *   attribute_at(index)
 *
 * Get the value of attribute at +index+
 */
static VALUE attribute_at(VALUE self, VALUE index)
{
  xmlTextReaderPtr reader;
  Data_Get_Struct(self, xmlTextReader, reader);

  if(index == Qnil) return Qnil;
  index = rb_funcall(index, rb_intern("to_i"), 0);

  xmlChar * value = xmlTextReaderGetAttributeNo(
      reader,
      NUM2INT(index)
  );
  if(value == NULL) return Qnil;

  VALUE MAYBE_UNUSED(enc) = rb_iv_get(self, "@encoding");
  VALUE rb_value = NOKOGIRI_STR_NEW2(value,
      RTEST(enc) ? StringValuePtr(enc) : NULL);
  xmlFree(value);
  return rb_value;
}
示例#8
0
文件: options.c 项目: aturley/ponyc
/**
 * Handle special cases of options like compile time defaults
 *
 * return CONTINUE if no errors else an ponyc_opt_process_t EXIT_XXX code.
 */
static ponyc_opt_process_t special_opt_processing(pass_opt_t *opt)
{
  // Suppress compiler errors due to conditional compilation
  MAYBE_UNUSED(opt);

#if defined(PONY_DEFAULT_PIC)
  #if (PONY_DEFAULT_PIC == true) || (PONY_DEFAULT_PIC == false)
    opt->pic = PONY_DEFAULT_PIC;
  #else
    #error "PONY_DEFAULT_PIC must be true or false"
  #endif
#endif

#if defined(USE_SCHEDULER_SCALING_PTHREADS)
  // Defined "scheduler_scaling_pthreads" so that SIGUSR2 is made available for
  // use by the signals package when not using signals for scheduler scaling
  define_build_flag("scheduler_scaling_pthreads");
#endif

  define_build_flag(PONY_DEFAULT_SSL);

  return CONTINUE;
}