/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to pywrap/pcipywrap.c

  • Committer: Suren A. Chilingaryan
  • Date: 2016-03-04 18:30:43 UTC
  • mfrom: (346.1.39 pcitool)
  • Revision ID: csa@suren.me-20160304183043-mjf6xvyermjh5olg
Integrate last part of Python code from Vasiliy Chernov

Show diffs side-by-side

added added

removed removed

Lines of Context:
552
552
    return;
553
553
}
554
554
 
555
 
PyObject* pcipywrap_lock(pcipywrap *self, const char *lock_id)
 
555
PyObject* lock(pcipywrap *self, const char *lock_id, pcilib_lock_flags_t flags)
556
556
{
557
557
    pcilib_lock_t* lock = pcilib_get_lock(self->ctx,
558
 
                                          PCILIB_LOCK_FLAG_PERSISTENT,
 
558
                                          flags,
559
559
                                          lock_id);
560
560
    if(!lock)
561
561
    {
574
574
    return PyLong_FromLong((long)1);
575
575
}
576
576
 
577
 
PyObject* pcipywrap_try_lock(pcipywrap *self, const char *lock_id)
 
577
PyObject* pcipywrap_lock(pcipywrap *self, const char *lock_id)
 
578
{
 
579
   return lock(self, lock_id, PCILIB_LOCK_FLAGS_DEFAULT);
 
580
}
 
581
 
 
582
PyObject* pcipywrap_lock_persistent(pcipywrap *self, const char *lock_id)
 
583
{
 
584
   return lock(self, lock_id, PCILIB_LOCK_FLAG_PERSISTENT);
 
585
}
 
586
 
 
587
 
 
588
PyObject* try_lock(pcipywrap *self, const char *lock_id, pcilib_lock_flags_t flags)
578
589
{
579
590
    pcilib_lock_t* lock = pcilib_get_lock(self->ctx,
580
 
                                          PCILIB_LOCK_FLAG_PERSISTENT,
 
591
                                          flags,
581
592
                                          lock_id);
582
593
    if(!lock)
583
594
    {
595
606
    return PyLong_FromLong((long)1);
596
607
}
597
608
 
 
609
PyObject* pcipywrap_try_lock(pcipywrap *self, const char *lock_id)
 
610
{
 
611
   return try_lock(self, lock_id, PCILIB_LOCK_FLAGS_DEFAULT);
 
612
}
 
613
 
 
614
PyObject* pcipywrap_try_lock_persistent(pcipywrap *self, const char *lock_id)
 
615
{
 
616
   return try_lock(self, lock_id, PCILIB_LOCK_FLAG_PERSISTENT);
 
617
}
 
618
 
 
619
PyObject* unlock(pcipywrap *self, const char *lock_id, pcilib_lock_flags_t flags)
 
620
{
 
621
    pcilib_lock_t* lock = pcilib_get_lock(self->ctx,
 
622
                                          flags,
 
623
                                          lock_id);
 
624
    if(!lock)
 
625
    {
 
626
        set_python_exception("Failed pcilib_get_lock");
 
627
        return NULL;
 
628
    }
 
629
 
 
630
    pcilib_unlock(lock);
 
631
    return PyLong_FromLong((long)1);
 
632
}
 
633
 
598
634
PyObject* pcipywrap_unlock(pcipywrap *self, const char *lock_id)
599
635
{
600
 
    pcilib_lock_t* lock = pcilib_get_lock(self->ctx,
601
 
                                          PCILIB_LOCK_FLAG_PERSISTENT,
602
 
                                          lock_id);
603
 
    if(!lock)
604
 
    {
605
 
        set_python_exception("Failed pcilib_get_lock");
606
 
        return NULL;
607
 
    }
 
636
   return unlock(self, lock_id, PCILIB_LOCK_FLAGS_DEFAULT);
 
637
}
608
638
 
609
 
    pcilib_unlock(lock);
610
 
    return PyLong_FromLong((long)1);
 
639
PyObject* pcipywrap_unlock_persistent(pcipywrap *self, const char *lock_id)
 
640
{
 
641
   return unlock(self, lock_id, PCILIB_LOCK_FLAG_PERSISTENT);
611
642
}
612
643
 
613
644