473,385 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Data type and register location errors on compilation

Hi all! I'm a French student currently doing an internship in Beijing. I have to simulate a mips machine running with the micro kernel l4. When i compile the kernel i got some compilation errors. I solved most of them but here I'm stuck and I hope you could help me.
Here is the error message :

/home/antoine/Final/pistachio/kernel/src/api/v4/exregs.cc:233:2: warning: #warning VU: do we have to preserve prios on ex-regs?
/home/antoine/Final/pistachio/kernel/src/api/v4/exregs.cc:248:2: warning: #warning eSk: Halting a thread with ongoing kernel operations is not supported
/home/antoine/Final/pistachio/kernel/src/api/v4/exregs.cc: In function `threadid_t sys_exchange_registers(threadid_t, word_t, word_t, word_t, word_t, word_t, threadid_t, bool)':
/home/antoine/Final/pistachio/kernel/src/api/v4/exregs.cc:333: error: data type of 'pgr' isn't suitable for a register
/home/antoine/Final/pistachio/kernel/src/api/v4/exregs.cc:333: error: register name given for non-register variable 'pgr'
/home/antoine/Final/pistachio/kernel/src/api/v4/exregs.cc:333: confused by earlier errors, bailing out
make[1]: *** [src/api/v4/exregs.o] Error 1

And here is the concerned code :

Expand|Select|Wrap|Line Numbers
  1. // Only allow exregs on:
  2.     //  - active threads
  3.     //  - in the same address space
  4.     //  - with a valid thread ID.
  5.     if ((! tcb->is_activated ()) || (! has_exregs_perms(tcb, dest_tid)) )
  6.     {
  7.     get_current_tcb ()->set_error_code (EINVALID_THREAD);
  8.     return_exchange_registers (threadid_t::nilthread (), 0, 0, 0, 0,
  9.                    threadid_t::nilthread (), 0);
  10.     }
  11.  
The 333 line is the one beginning with return_... and I've searched what is pgr all over the file but I've found nor variables neither functions with this name.
Hope you'll understand this better than me ;)
Thanks
Antoine
Jul 6 '07 #1
7 2984
weaknessforcats
9,208 Expert Mod 8TB
Is it in a library? It may not be in your source code.
Jul 6 '07 #2
In fact I've continued to search and i ve found this portion of code in an included file :

Expand|Select|Wrap|Line Numbers
  1. #define return_exchange_registers(result, control, sp, ip, flags, pager, handle)    \
  2. {                                \
  3.     register word_t ctrl asm("$4") = control;    /* a0 */    \
  4.     register word_t sp_r asm("$5") = sp;    /* a1 */    \
  5.     register word_t ip_r asm("$6") = ip;    /* a2 */    \
  6.     register word_t flg asm("$7") = flags;    /* a3 */    \
  7.     register threadid_t pgr asm("$8") = pager;    /* t0 */    \
  8.     register word_t hdl asm("$9") = handle;    /* t1 */    \
  9. \
  10.     __asm__ __volatile__ (                    \
  11.     "" : : "r" (ctrl), "r" (sp_r), "r" (ip_r),        \
  12.     "r" (flg), "r" (pgr), "r" (hdl)                \
  13.     );                                \
  14.     return (result);                        \
  15. }
  16.  
With this it becomes a bit clearer. I think that we can't put a threadid_t into a register. But what can i do to solve that? Is register a predefined type in C++ or not?
I hope it would help you to help me ;)
Bye
Antoine
Jul 9 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
register is a strage class specifer. It suggests to the compiler that the variable should be kept in a register instead of existing as a variable in memory. The compiler is free to ignore this suggestion.

A register is most likely 32 or 64 bits depending on the chip. If your threadid_t fits you can use a register. This code:
register threadid_t pgr asm("$8") = pager; /* t0 */ \
says the threadid_t will fit in a register.

In this line, pgr is the name of the variable. threadid_t is the type. and register is the storage class specifer.

However, this error:
/home/antoine/Final/pistachio/kernel/src/api/v4/exregs.cc: In function `threadid_t sys_exchange_registers(threadid_t, word_t, word_t, word_t, word_t, word_t, threadid_t, bool)':
/home/antoine/Final/pistachio/kernel/src/api/v4/exregs.cc:333: error: data type of 'pgr' isn't suitable for a register
says that the data type of pgr (that's threadid_t) won't fit in a register.

What does thread_t look like? Is it a struct?? Or is it a typedef of some kind??
Jul 9 '07 #4
Hi thank you for your help. Here is how threadid_t is defined :

public:
042 static threadid_t anythread() {
043 threadid_t tid;
044 tid.raw = (word_t)-1UL;
045 return tid;
046 };
047
048 static threadid_t waitnotify() {
049 threadid_t tid;
050 tid.raw = (word_t)-2UL;
051 return tid;
052 };
053
054 static threadid_t anylocalthread() {
055 threadid_t tid;
056 tid.raw = (word_t)-64UL;
057 return tid;
058 }
059
060 static threadid_t nilthread()
061 {
062 threadid_t tid;
063 tid.raw = 0;
064 return tid;
065 }
066
067 static threadid_t irqthread(word_t irq)
068 {
069 threadid_t tid;
070 tid.raw = 0;
071 tid.global.version = 1;
072 tid.global.threadno = irq;
073 return tid;
074 }
075
076 static threadid_t threadid(word_t threadno, word_t version)
077 {
078 threadid_t tid;
079 tid.raw = 0;
080 tid.global.version = version;
081 tid.global.threadno = threadno;
082 return tid;
083 }

If it's not enough you can see the entire file at :
http://www.disy.cse.unsw.edu.au/lxr/aos-2006/source/pistachio/kernel/include/api/v4/thread.h#039
I hope it will help you because it donts help me so much ;)
Bye and thanks again.
Antoine
Jul 10 '07 #5
weaknessforcats
9,208 Expert Mod 8TB
Your previous post has code like this:
static threadid_t irqthread(word_t irq)
068 {
069 threadid_t tid;
070 tid.raw = 0;
071 tid.global.version = 1;
072 tid.global.threadno = irq;
073 return tid;
074 }
Note lines 70, 71 and 72. They show a thread_t has members. That tells me threadid_t cannot fit in a register unless you can show me the definiton of threadid_t so I can see that it is 32 bits or less.

What you are showing me are static functions that return a threadid_t but nowhere to I see the threadid_t itself.

Somewhere, there should be something like:
Expand|Select|Wrap|Line Numbers
  1. struct threadid_t
  2. {
  3.       //with members declaredin here
  4.  
  5. };
  6.  
Jul 10 '07 #6
Hi. I think I've found were threadid_t is defined. Here is the code :
Expand|Select|Wrap|Line Numbers
  1. private:
  2.     union {
  3.     word_t raw;
  4.  
  5.     struct {
  6.         BITFIELD2( word_t,
  7.                zero    : TID_LOCAL_ID_ZERO_BITS,
  8.                id    : TID_LOCAL_ID_BITS );
  9.     } local;
  10.  
  11.     struct {
  12.         BITFIELD2( word_t,
  13.                version    : TID_GLOBAL_VERSION_BITS,
  14.                threadno    : TID_GLOBAL_THREADNO_BITS );
  15.     } global;
  16.     };
  17. } __attribute__((packed));
  18.  
I've found in another file these definitions :
Expand|Select|Wrap|Line Numbers
  1. #if defined(CONFIG_IS_32BIT)
  2. # define L4_ARCH_CONST(const)        const##_32
  3. #elif defined(CONFIG_IS_64BIT)
  4. # define L4_ARCH_CONST(const)        const##_64
  5. #else
  6. # error undefined architecture width (32/64bit?)
  7. #endif
  8.  
  9. #define L4_GLOBAL_THREADNO_BITS_32    18
  10. #define L4_GLOBAL_INTRNO_BITS_32    18
  11. #define L4_GLOBAL_VERSION_BITS_32    14
  12. #define L4_LOCAL_ID_BITS_32        26
  13. #define L4_LOCAL_ID_ZERO_BITS_32    6
  14. #define L4_FPAGE_BASE_BITS_32        22
  15.  
  16. #define L4_GLOBAL_THREADNO_BITS_64    32
  17. #define L4_GLOBAL_INTRNO_BITS_64    32
  18. #define L4_GLOBAL_VERSION_BITS_64    32
  19. #define L4_LOCAL_ID_BITS_64        58
  20. #define L4_LOCAL_ID_ZERO_BITS_64    6
  21. #define L4_FPAGE_BASE_BITS_64        54
  22.  
  23. #define L4_GLOBAL_THREADNO_BITS        L4_ARCH_CONST(L4_GLOBAL_THREADNO_BITS)
  24. #define L4_GLOBAL_INTRNO_BITS        L4_ARCH_CONST(L4_GLOBAL_INTRNO_BITS)
  25. #define L4_GLOBAL_VERSION_BITS        L4_ARCH_CONST(L4_GLOBAL_VERSION_BITS)
  26. #define L4_LOCAL_ID_BITS        L4_ARCH_CONST(L4_LOCAL_ID_BITS)
  27. #define L4_LOCAL_ID_ZERO_BITS        L4_ARCH_CONST(L4_LOCAL_ID_ZERO_BITS)
  28. #define L4_FPAGE_BASE_BITS        L4_ARCH_CONST(L4_FPAGE_BASE_BITS)
  29.  
If I've well understand, the problem is that 32 bits for the number + 32 bits for the version + the word_t doesn't fit in a register ?
But the fact is that these constants does not seem to have precisely the same name (TID_... vs L4...) Have I found the good definitions?
Antoine
Jul 11 '07 #7
weaknessforcats
9,208 Expert Mod 8TB
This code:
private:
union {
word_t raw;

struct {
BITFIELD2( word_t,
zero : TID_LOCAL_ID_ZERO_BITS,
id : TID_LOCAL_ID_BITS );
} local;

struct {
BITFIELD2( word_t,
version : TID_GLOBAL_VERSION_BITS,
threadno : TID_GLOBAL_THREADNO_BITS );
} global;
};
} __attribute__((packed));
doesn't say threadid_t anywhere. But assuming this is the declaration, I can see that it is a union of a word_t, a struct local and a struct global.

The threadid_t will be the largest of these three members:

word_t -> I don't know how buig this is
struct local -> has a bitfield member some of the members of the bitfield are defined to be TID_LOCAL_ID_ZERO_BITS and TID_GLOBAL_THREADNO_BITS.

If you find something like:

#define TID_GLOBAL_THREADNO_BITS 25

then that bitfield member is 5 bits since 25 only requires 5 bits.

Field members are packed into integers and no field is split between integers.

Have you tried to sizeof(threadid_t) to see how large it is??

I suspect the original processor has a bigger word than your micro kernal 14.

One work around is to use actual integer variables instead of register variables.
Jul 11 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: Marina | last post by:
Hi, if anyone can help on this, please! This is driving me crazy. I have a user control hierarchy several levels deep that derive for UserControl (windows). The class that is at the top level,...
4
by: Ced | last post by:
Hi, i'm not an expert in C but i try to compile BTNG software under linux kernel 2.4.2-2. I get these errors at the very first stage. Does someone could have a rapid look on this and tell me...
5
by: Adam McKee | last post by:
We are using Visual Studio.NET 2003 in our project with .NET framework 1.1. One of our libraries is a mixed-mode dll assembly consisting of one managed C++ library, and several unmanaged C++...
6
by: Mikael Syska | last post by:
Hi asp.net guru's, i have developped this site in ASP.NET 2.0 in the 2005 web delopment beta1 version from microsoft, the site works fine local, but when I move it to my IIS 6.0 with ASP.NET 2.0 I...
1
by: Michael Tissington | last post by:
I'm trying to convert a project from VS2003 to VS2005 After conversion all of my TagPrefix are not recognized in the body. <%@ Register TagPrefix="Oaklodge" TagName="Curve"...
0
by: qiang | last post by:
Hi everyone, Could you please take a look at an exception for ASP.NET application? My ASP.NET application is using Infragistics WebChart control. I encounter an exception below when...
12
by: Sensei | last post by:
Hi again! I have recently encountered an old code in K&R style which declared function parameters as register. That puzzles me, and I know this is implementation defined, and depends on...
0
by: ma740988 | last post by:
I often peruse source that use memory mapped registers as a configuration and/or command and status interface between embedded software and FPGA logic. In doing so you're given a register name...
9
by: gavy7210 | last post by:
hello friends i am new to struts. i want to add the user information in the database and then display it back to him. i am using struts 1.2,Eclipse Platform Version: 3.4.2,mySql 5.0.1,jdk...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.