sc_semaphore.hh revision 12841
11689SN/A/*
21689SN/A * Copyright 2018 Google, Inc.
31689SN/A *
41689SN/A * Redistribution and use in source and binary forms, with or without
51689SN/A * modification, are permitted provided that the following conditions are
61689SN/A * met: redistributions of source code must retain the above copyright
71689SN/A * notice, this list of conditions and the following disclaimer;
81689SN/A * redistributions in binary form must reproduce the above copyright
91689SN/A * notice, this list of conditions and the following disclaimer in the
101689SN/A * documentation and/or other materials provided with the distribution;
111689SN/A * neither the name of the copyright holders nor the names of its
121689SN/A * contributors may be used to endorse or promote products derived from
131689SN/A * this software without specific prior written permission.
141689SN/A *
151689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
161689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
171689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
181689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
191689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
201689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
211689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
221689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
231689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
241689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
251689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
261689SN/A *
272665SN/A * Authors: Gabe Black
282665SN/A */
291689SN/A
301689SN/A#ifndef __SYSTEMC_EXT_CHANNEL_SC_SEMAPHORE_HH__
319480Snilay@cs.wisc.edu#define __SYSTEMC_EXT_CHANNEL_SC_SEMAPHORE_HH__
329480Snilay@cs.wisc.edu
331061SN/A#include "../core/sc_object.hh"
347720Sgblack@eecs.umich.edu#include "sc_semaphore_if.hh"
3512334Sgabeblack@google.com
366214SN/Anamespace sc_core
377720Sgblack@eecs.umich.edu{
381061SN/A
391061SN/Aclass sc_semaphore : public sc_semaphore_if, public sc_object
401061SN/A{
411061SN/A  public:
421061SN/A    explicit sc_semaphore(int);
431061SN/A    sc_semaphore(const char *name, int);
441061SN/A
451061SN/A    virtual int wait();
467720Sgblack@eecs.umich.edu    virtual int trywait();
471061SN/A    virtual int post();
482292SN/A    virtual int get_value() const;
491061SN/A
502292SN/A    virtual const char *kind() const;
512292SN/A
527720Sgblack@eecs.umich.edu  private:
532292SN/A    // Disabled
542292SN/A    sc_semaphore(const sc_semaphore &) :
556221SN/A            sc_interface(), sc_semaphore_if(), sc_object()
562292SN/A    {}
572292SN/A
581061SN/A    sc_semaphore &operator = (const sc_semaphore &) { return *this; }
591061SN/A};
601061SN/A
611061SN/A} // namespace sc_core
622292SN/A
632292SN/A#endif  //__SYSTEMC_EXT_CHANNEL_SC_SEMAPHORE_HH__
642292SN/A