Exemple #1
0
/* Doesn't clear its own data, since it's going to be called a lot. */
static void _cpu_wake_channel_for_signal(EV_P_ struct ev_signal *ev, int revents) {
  struct thread_info *ti = (struct thread_info*)ev->data;

  if(ev->signum == SIGHUP) {
    THDEBUG("%d: channel %p got signal.\n", getpid(), ti->channel);
  }
  cpu_channel_send(ti->state, ti->c, ti->channel, ti->c->current_thread);
}
Exemple #2
0
OBJECT cpu_event_wait_signal(STATE, cpu c, OBJECT channel, int sig) {
  struct thread_info *ti, *tnext;
  OBJECT id;
  environment e = environment_current();

  ti = (struct thread_info*)(state->thread_infos);
  while (ti) {
    tnext = ti->next;

    if (ti->type == SIGNAL && ti->sig == sig) {
      cpu tc = ti->c;
      STATE = ti->state;
      OBJECT tchan = ti->channel;
      _cpu_event_unregister_info(state, ti);
      cpu_channel_send(state, tc, tchan, Qnil);
      break;
    }
    ti = tnext;
  }

  /* Here is a short period during which a incoming signal would not
     be delivered to either an old handler or the new handler. */

  ti = ALLOC_N(struct thread_info, 1);
  ti->fd = 0;
  ti->type = SIGNAL;
  ti->state = state;
  ti->c = c;
  ti->channel = channel;
  ti->sig = sig;
  ti->stopper = (stopper_cb)ev_signal_stop;
  id = _cpu_event_register_info(state, ti);

  THDEBUG("%d: channel for signal: %p\n", getpid(), channel);

  ev_signal_init(&ti->ev.signal, _cpu_wake_channel_for_signal, sig);
  ti->ev.signal.data = ti;
  ev_signal_start(e->sig_event_base, &ti->ev.signal);

  return id;
}
HB_Bool HB_ThaiShape(HB_ShaperItem *item)
{
    HB_Bool openType = FALSE;
    unsigned short *logClusters = item->log_clusters;
    int i;
    int clusterIndex;
    int cStart, cEnd;
    int fristGlyphIndex;
    int prevOutputIndex;
    int outputClusterLength;

    HB_ShaperItem shapedItem = *item;

    THDEBUG("item->item.pos: %d, item->item.length: %d", item->item.pos, item->item.length);

    ThaiShapeCategory glyphSet = thaiCheckShapeCategory(item);

    HB_UChar16 * output = (HB_UChar16 *)malloc(sizeof(HB_UChar16) * (item->item.length << 1));
    hb_int32 *charIndex = (hb_int32 *)malloc(sizeof(hb_int32) * (item->item.length << 1));
    hb_int32 *clusterStart = (hb_int32 *)malloc(sizeof(hb_int32) * (item->item.length << 1));
    int clusterCount = 0;

    hb_int32 strLen = thaiCompose(item->string, item->item.pos, item->item.length, glyphSet,
            CH_DOTTED_CIRCLE, output, charIndex, &clusterCount, clusterStart);
    THDEBUG("reordered strLen: %d", strLen);

#ifdef THAI_DEBUG
    THDEBUG("clusterCount: %d", clusterCount);
    for (i = 0; i < strLen; ++i) {
        THDEBUG("charIndex[%d]: %d, clusterStart[%d]: %d", i, charIndex[i], i, clusterStart[i]);
    }
#endif

    shapedItem.string = output;
    shapedItem.stringLength = strLen;

    fristGlyphIndex = 0;
    prevOutputIndex = 0;
    for (clusterIndex = 0; clusterIndex < clusterCount; ++clusterIndex) {
        cStart = clusterStart[clusterIndex];
        if (clusterIndex == clusterCount - 1) {
            cEnd = item->item.length;
        } else {
            cEnd = clusterStart[clusterIndex + 1];
        }

        outputClusterLength = 0;
        for (i = prevOutputIndex; i < strLen && charIndex[i] < cEnd; ++i) {
            ++outputClusterLength;
        }
        THDEBUG("        outputClusterLength %d", outputClusterLength);

        shapedItem.item.pos = prevOutputIndex;
        shapedItem.item.length = outputClusterLength;
        shapedItem.glyphs = item->glyphs + fristGlyphIndex;
        shapedItem.attributes = item->attributes + fristGlyphIndex;
        shapedItem.advances = item->advances + fristGlyphIndex;
        shapedItem.offsets = item->offsets + fristGlyphIndex;
        shapedItem.num_glyphs = item->num_glyphs - fristGlyphIndex;
        shapedItem.log_clusters = item->log_clusters + cStart;

        HB_BasicShape(&shapedItem);

        for (i = cStart; i < cEnd; ++i) {
            item->log_clusters[i] = fristGlyphIndex;
        }

        prevOutputIndex += outputClusterLength;
        fristGlyphIndex += shapedItem.num_glyphs;
    }

    for (i = item->item.length; i < prevOutputIndex; ++i) {
        item->log_clusters[i] = 0;
    }

    item->num_glyphs = fristGlyphIndex;
    THDEBUG("shapedItem.num_glyphs: %d", item->num_glyphs);

    free(clusterStart);
    free(charIndex);
    free(output);
    return TRUE;
}