Ejemplo n.º 1
0
static int __init __atomic_init(void)
{
    __atomic_t a;

    printk("testing ldrex, strex....\n");
    __atomic_add(1, &a);
    __atomic_add_fail(1, &a);
    printk("tested ldrex, strex\n");

    __atomic_add_hang(1, &a);
    printk("never arrive here\n");

    return 0;
}
Ejemplo n.º 2
0
static int32_t os2_mixer_event(uint32_t ulStatus, PMCI_MIX_BUFFER pBuffer,
                               uint32_t ulFlags)
{
  sa_stream_t * s;

  /* check for errors */
  if (ulFlags & MIX_STREAM_ERROR)
    os2_error(0, "os2_mixer_event", "MIX_STREAM_ERROR - status=", ulStatus);

  if (!(ulFlags & MIX_WRITE_COMPLETE))
    return os2_error(TRUE, "os2_mixer_event",
                     "unexpected event - flag=", ulFlags);

  if (!pBuffer || !pBuffer->ulUserParm)
    return os2_error(TRUE, "os2_mixer_event", "null pointer", 0);

  /* Note: this thread doesn't use a mutex to avoid a deadlock with the one
   * DART uses to prevent MCI operations while this function is running */
  s = (sa_stream_t *)pBuffer->ulUserParm;

  /* update the number of buffers that are now in use */
  s->usedCnt += __atomic_xchg(&s->usedNew, 0);
  s->usedCnt--;

  /* if fewer than 2 buffers are in use, enter recovery mode -
   * if we wait until they're all free, it's often too late; */
  if (s->usedCnt < s->usedMin) {
    s->playing = FALSE;
    os2_pause_device(s->hwDeviceID, FALSE);
    os2_error(0, "os2_mixer_event",
              "too few buffers in use - recovering", 0);
  }

  /* pass the number of newly played bytes to the other thread;
   * get the time so the other thread can estimate how many
   * additional bytes have been consumed since this event */
  __atomic_add(&s->writeNew, pBuffer->ulBufferLength);
  pBuffer->ulBufferLength = 0;
  DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT,
                  (void*)&s->writeTime, sizeof(s->writeTime));

  /* signal the decode thread that a buffer is available */
  __atomic_increment(&s->freeNew);

  return TRUE;
}
Ejemplo n.º 3
0
 void operator++()
 {
     __atomic_add(&value_, 1);
 }
Ejemplo n.º 4
0
static int __decrement_if_positive( volatile int *dest )
{
    if( *dest > 0 )
        return( __atomic_add( dest, -1 ) <= 0 );
    return( 0 );
}