summaryrefslogtreecommitdiff
path: root/Source/DirectFB/src/core/core_parts.h
blob: 31b7563ad98e877384ec55656eafabb4d616f3a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
   (c) Copyright 2001-2009  The world wide DirectFB Open Source Community (directfb.org)
   (c) Copyright 2000-2004  Convergence (integrated media) GmbH

   All rights reserved.

   Written by Denis Oliver Kropp <dok@directfb.org>,
              Andreas Hundt <andi@fischlustig.de>,
              Sven Neumann <neo@directfb.org>,
              Ville Syrjälä <syrjala@sci.fi> and
              Claudio Ciccani <klan@users.sf.net>.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the
   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
*/

#ifndef __CORE_PARTS_H__
#define __CORE_PARTS_H__

#include <fusion/types.h>
#include <fusion/lock.h>

#include <directfb.h>

#include <core/coretypes.h>
#include <core/coredefs.h>


typedef DFBResult (*CoreInitialize)( CoreDFB *core,
                                     void    *data_local,
                                     void    *data_shared );

typedef DFBResult (*CoreJoin)      ( CoreDFB *core,
                                     void    *data_local,
                                     void    *data_shared );

typedef DFBResult (*CoreShutdown)  ( void    *data_local,
                                     bool     emergency );

typedef DFBResult (*CoreLeave)     ( void    *data_local,
                                     bool     emergency );

typedef DFBResult (*CoreSuspend)   ( void    *data_local );

typedef DFBResult (*CoreResume)    ( void    *data_local );


typedef struct {
     const char     *name;

     int             size_local;
     int             size_shared;

     CoreInitialize  Initialize;
     CoreJoin        Join;
     CoreShutdown    Shutdown;
     CoreLeave       Leave;
     CoreSuspend     Suspend;
     CoreResume      Resume;

     void           *data_local;
     void           *data_shared;

     bool            initialized;
} CorePart;


DFBResult dfb_core_part_initialize( CoreDFB  *core,
                                    CorePart *core_part );

DFBResult dfb_core_part_join      ( CoreDFB  *core,
                                    CorePart *core_part );

DFBResult dfb_core_part_shutdown  ( CoreDFB  *core,
                                    CorePart *core_part,
                                    bool      emergency );

DFBResult dfb_core_part_leave     ( CoreDFB  *core,
                                    CorePart *core_part,
                                    bool      emergency );


#define DFB_CORE_PART(part,Type)                                               \
                                                                               \
static DFBResult dfb_##part##_initialize( CoreDFB           *core,             \
                                          DFB##Type         *local,            \
                                          DFB##Type##Shared *shared );         \
                                                                               \
static DFBResult dfb_##part##_join      ( CoreDFB           *core,             \
                                          DFB##Type         *local,            \
                                          DFB##Type##Shared *shared );         \
                                                                               \
static DFBResult dfb_##part##_shutdown  ( DFB##Type         *local,            \
                                          bool               emergency );      \
                                                                               \
static DFBResult dfb_##part##_leave     ( DFB##Type         *local,            \
                                          bool               emergency );      \
                                                                               \
static DFBResult dfb_##part##_suspend   ( DFB##Type         *local );          \
                                                                               \
static DFBResult dfb_##part##_resume    ( DFB##Type         *local );          \
                                                                               \
CorePart dfb_##part = {                                                        \
     .name        = #part,                                                     \
                                                                               \
     .size_local  = sizeof(DFB##Type),                                         \
     .size_shared = sizeof(DFB##Type##Shared),                                 \
                                                                               \
     .Initialize  = (void*)dfb_##part##_initialize,                            \
     .Join        = (void*)dfb_##part##_join,                                  \
     .Shutdown    = (void*)dfb_##part##_shutdown,                              \
     .Leave       = (void*)dfb_##part##_leave,                                 \
     .Suspend     = (void*)dfb_##part##_suspend,                               \
     .Resume      = (void*)dfb_##part##_resume,                                \
}


#endif